Browse Source

first commit

xusonglin 5 years ago
parent
commit
346950c899
58 changed files with 2739 additions and 0 deletions
  1. 0 0
      README.MD
  2. 126 0
      pom.xml
  3. 30 0
      src/main/java/com/jkcredit/asychronous/AsychronousApplication.java
  4. 36 0
      src/main/java/com/jkcredit/asychronous/common/ResponseEntity.java
  5. 33 0
      src/main/java/com/jkcredit/asychronous/config/CorsConfig.java
  6. 30 0
      src/main/java/com/jkcredit/asychronous/config/RabbitConfig.java
  7. 33 0
      src/main/java/com/jkcredit/asychronous/controller/CarController.java
  8. 54 0
      src/main/java/com/jkcredit/asychronous/controller/ChargeController.java
  9. 28 0
      src/main/java/com/jkcredit/asychronous/controller/CreditChargeController.java
  10. 22 0
      src/main/java/com/jkcredit/asychronous/controller/LoginController.java
  11. 71 0
      src/main/java/com/jkcredit/asychronous/controller/ManController.java
  12. 38 0
      src/main/java/com/jkcredit/asychronous/controller/UserController.java
  13. 25 0
      src/main/java/com/jkcredit/asychronous/dao/CarRepository.java
  14. 13 0
      src/main/java/com/jkcredit/asychronous/dao/CarResultRepository.java
  15. 65 0
      src/main/java/com/jkcredit/asychronous/dao/ChargeRepository.java
  16. 25 0
      src/main/java/com/jkcredit/asychronous/dao/CreditChargeRepository.java
  17. 13 0
      src/main/java/com/jkcredit/asychronous/dao/ManFtpResultRepository.java
  18. 20 0
      src/main/java/com/jkcredit/asychronous/dao/ManRepository.java
  19. 13 0
      src/main/java/com/jkcredit/asychronous/dao/ManResultRepository.java
  20. 20 0
      src/main/java/com/jkcredit/asychronous/dao/UserRepository.java
  21. 31 0
      src/main/java/com/jkcredit/asychronous/entity/Car.java
  22. 34 0
      src/main/java/com/jkcredit/asychronous/entity/CarResult.java
  23. 34 0
      src/main/java/com/jkcredit/asychronous/entity/Charge.java
  24. 35 0
      src/main/java/com/jkcredit/asychronous/entity/CreditCharge.java
  25. 49 0
      src/main/java/com/jkcredit/asychronous/entity/Man.java
  26. 59 0
      src/main/java/com/jkcredit/asychronous/entity/ManFtpResult.java
  27. 77 0
      src/main/java/com/jkcredit/asychronous/entity/ManResult.java
  28. 21 0
      src/main/java/com/jkcredit/asychronous/entity/User.java
  29. 48 0
      src/main/java/com/jkcredit/asychronous/ftp/CarDownloadRoute.java
  30. 48 0
      src/main/java/com/jkcredit/asychronous/ftp/ManDownloadRoute.java
  31. 54 0
      src/main/java/com/jkcredit/asychronous/job/CarJob.java
  32. 111 0
      src/main/java/com/jkcredit/asychronous/job/ManJob.java
  33. 52 0
      src/main/java/com/jkcredit/asychronous/mq/RabbitMqReceiver.java
  34. 78 0
      src/main/java/com/jkcredit/asychronous/process/CarLocationFileProcessor.java
  35. 224 0
      src/main/java/com/jkcredit/asychronous/process/ManLocationFileProcessor.java
  36. 19 0
      src/main/java/com/jkcredit/asychronous/service/CarResultService.java
  37. 17 0
      src/main/java/com/jkcredit/asychronous/service/CarService.java
  38. 22 0
      src/main/java/com/jkcredit/asychronous/service/ChargeService.java
  39. 14 0
      src/main/java/com/jkcredit/asychronous/service/CreditChargeService.java
  40. 15 0
      src/main/java/com/jkcredit/asychronous/service/ManFtpResultService.java
  41. 15 0
      src/main/java/com/jkcredit/asychronous/service/ManResultService.java
  42. 20 0
      src/main/java/com/jkcredit/asychronous/service/ManService.java
  43. 35 0
      src/main/java/com/jkcredit/asychronous/service/UserService.java
  44. 26 0
      src/main/java/com/jkcredit/asychronous/service/impl/CarResultServiceImpl.java
  45. 33 0
      src/main/java/com/jkcredit/asychronous/service/impl/CarServiceImpl.java
  46. 51 0
      src/main/java/com/jkcredit/asychronous/service/impl/ChargeServiceImpl.java
  47. 27 0
      src/main/java/com/jkcredit/asychronous/service/impl/CreditChargeServiceImpl.java
  48. 26 0
      src/main/java/com/jkcredit/asychronous/service/impl/ManFtpResultServiceImpl.java
  49. 26 0
      src/main/java/com/jkcredit/asychronous/service/impl/ManResultServiceImpl.java
  50. 36 0
      src/main/java/com/jkcredit/asychronous/service/impl/ManServiceImpl.java
  51. 36 0
      src/main/java/com/jkcredit/asychronous/service/impl/UserServiceImpl.java
  52. 325 0
      src/main/java/com/jkcredit/asychronous/util/ExcelUtil.java
  53. 94 0
      src/main/java/com/jkcredit/asychronous/util/FtpUtil.java
  54. 56 0
      src/main/resources/application-dev.yml
  55. 56 0
      src/main/resources/application-prod.yml
  56. 3 0
      src/main/resources/bootstrap.yml
  57. 121 0
      src/main/resources/logback-spring.xml
  58. 16 0
      src/test/java/com/jkcredit/asychronous/AsychronousApplicationTests.java

+ 0 - 0
README.MD


+ 126 - 0
pom.xml

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.jkcredit</groupId>
+    <artifactId>asychronous</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>asychronous</name>
+    <description>Demo project for Spring Boot</description>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.0.3.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+            <version>2.18.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-ftp</artifactId>
+            <version>2.18.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- 引入poi,解析workbook视图 -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>3.16</version>
+        </dependency>
+
+        <!--easypoi 开始-->
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-base</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-web</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-annotation</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <!--easypoi 结束-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-mongodb</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-context</artifactId>
+            <version>2.0.2.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.28</version>
+        </dependency>
+
+    </dependencies>
+
+    <!--<dependencyManagement>-->
+        <!--<dependencies>-->
+            <!--<dependency>-->
+                <!--<groupId>org.springframework.cloud</groupId>-->
+                <!--<artifactId>spring-cloud-dependencies</artifactId>-->
+                <!--<version>Finchley.RELEASE</version>-->
+                <!--<type>pom</type>-->
+                <!--<scope>import</scope>-->
+            <!--</dependency>-->
+        <!--</dependencies>-->
+    <!--</dependencyManagement>-->
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 30 - 0
src/main/java/com/jkcredit/asychronous/AsychronousApplication.java

@@ -0,0 +1,30 @@
+package com.jkcredit.asychronous;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author sunzhaoning
+ */
+@EnableScheduling
+@SpringBootApplication
+public class AsychronousApplication {
+
+    @Autowired
+    private RestTemplateBuilder builder;
+
+    @Bean
+    public RestTemplate restTemplate() {
+        return builder.setConnectTimeout(3000).setReadTimeout(3000).build();
+    }
+
+    public static void main(String[] args) {
+        SpringApplication.run(AsychronousApplication.class, args);
+    }
+}

+ 36 - 0
src/main/java/com/jkcredit/asychronous/common/ResponseEntity.java

@@ -0,0 +1,36 @@
+package com.jkcredit.asychronous.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午2:47
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ResponseEntity {
+    private int code = 200;
+    private String msg = "OK";
+    private String type;
+    private Object data;
+
+
+    public ResponseEntity(Object data) {
+        this.data = data;
+    }
+
+    public ResponseEntity(Object data, String type) {
+        this.data = data;
+        this.type = type;
+    }
+
+    public ResponseEntity(int code, String msg, Object data) {
+        this.code = code;
+        this.msg = msg;
+        this.data = data;
+    }
+}

+ 33 - 0
src/main/java/com/jkcredit/asychronous/config/CorsConfig.java

@@ -0,0 +1,33 @@
+package com.jkcredit.asychronous.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;  
+import org.springframework.web.cors.CorsConfiguration;  
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;  
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * 解决跨域
+ * @author sunzhaoning
+ */
+@Configuration  
+public class CorsConfig {
+
+    private CorsConfiguration buildConfig() {  
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        // 1允许任何域名使用
+        corsConfiguration.addAllowedOrigin("*");
+        // 2允许任何头
+        corsConfiguration.addAllowedHeader("*");
+        // 3允许任何方法(post、get等)
+        corsConfiguration.addAllowedMethod("*");
+        return corsConfiguration;  
+    }  
+  
+    @Bean  
+    public CorsFilter corsFilter() {  
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();  
+        source.registerCorsConfiguration("/**", buildConfig());
+        return new CorsFilter(source);  
+    }  
+}

+ 30 - 0
src/main/java/com/jkcredit/asychronous/config/RabbitConfig.java

@@ -0,0 +1,30 @@
+package com.jkcredit.asychronous.config;
+
+import org.springframework.amqp.core.*;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+ 
+@Configuration
+public class RabbitConfig {
+
+    @Bean
+    public Queue QueueA() {
+        return new Queue("marriage");
+    }
+
+    /**
+     * Fanout 就是我们熟悉的广播模式或者订阅模式,给Fanout交换机发送消息,绑定了这个交换机的所有队列都收到这个消息。
+     * @return
+     */
+    @Bean
+    FanoutExchange fanoutExchange() {
+        return new FanoutExchange("marriage");
+    }
+ 
+ 
+    @Bean
+    Binding bindingExchangeA(Queue QueueA, FanoutExchange fanoutExchange) {
+        return BindingBuilder.bind(QueueA).to(fanoutExchange);
+    }
+
+}

+ 33 - 0
src/main/java/com/jkcredit/asychronous/controller/CarController.java

@@ -0,0 +1,33 @@
+package com.jkcredit.asychronous.controller;
+
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.Car;
+import com.jkcredit.asychronous.service.CarService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午2:55
+ */
+@RestController
+@RequestMapping("car")
+@Slf4j
+public class CarController {
+
+
+    @Autowired
+    private CarService carService;
+
+    @PostMapping("receive")
+    public Object receiveCar(@RequestBody Car car) {
+        car.setTime(System.currentTimeMillis());
+        carService.insert(car);
+        log.info("插入成功:{}", car);
+        return new ResponseEntity(car);
+    }
+
+
+}

+ 54 - 0
src/main/java/com/jkcredit/asychronous/controller/ChargeController.java

@@ -0,0 +1,54 @@
+package com.jkcredit.asychronous.controller;
+
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.Charge;
+import com.jkcredit.asychronous.service.ChargeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author sunzhaoning
+ */
+@RestController
+@RequestMapping("charge")
+public class ChargeController {
+
+    @Autowired
+    private ChargeService chargeService;
+
+
+    @PostMapping("countList/{user}/{api}/{start}/{end}")
+    public ResponseEntity findList(@PathVariable String user, @PathVariable String api, @PathVariable Long start, @PathVariable Long end) {
+        List<Charge> chargeList = chargeService.findByUserAndTime(user, api, start, end);
+        if (chargeList.size() > 0) {
+            return new ResponseEntity(200, "查询成功", chargeList);
+        }
+        return null;
+    }
+
+    @PostMapping("count/{user}/{api}/{start}/{end}")
+    public ResponseEntity findCount(@PathVariable String user, @PathVariable String api, @PathVariable Long start, @PathVariable Long end) {
+        return new ResponseEntity(200, "查询成功", chargeService.findCountByUserAndTime(user, api, start, end));
+    }
+
+    @PostMapping("test/{user}/{api}/{start}/{end}/{page}/{size}")
+    public Page<Charge> test(@PathVariable String user, @PathVariable String api, @PathVariable Long start, @PathVariable Long end, @PathVariable int page, @PathVariable int size) {
+        Pageable pageable = new PageRequest(page, size);
+        Page<Charge> pages = chargeService.page(user, api, start, end, pageable);
+        return pages;
+    }
+
+    @PostMapping("manCount/{start}/{end}")
+    public int manCount(@PathVariable Long start, @PathVariable Long end) {
+        String api = "MAN_CHECK";
+        return chargeService.findCountByTime(api, start, end);
+    }
+}

+ 28 - 0
src/main/java/com/jkcredit/asychronous/controller/CreditChargeController.java

@@ -0,0 +1,28 @@
+package com.jkcredit.asychronous.controller;
+
+import com.jkcredit.asychronous.service.CreditChargeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author sunzhaoning
+ */
+@RestController
+@RequestMapping("credit/charge")
+public class CreditChargeController {
+
+    @Autowired
+    private CreditChargeService creditChargeService;
+
+    @PostMapping("count/{start}/{end}")
+    public int count(@PathVariable Long start,@PathVariable Long end){
+        int count = 0;
+        if(start>0&& end>0){
+            count = creditChargeService.findChargeByTime(start,end);
+        }
+        return count;
+    }
+}

+ 22 - 0
src/main/java/com/jkcredit/asychronous/controller/LoginController.java

@@ -0,0 +1,22 @@
+package com.jkcredit.asychronous.controller;
+
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author sunzhaoning
+ */
+@RestController
+@RequestMapping("/m/admin")
+public class LoginController {
+
+    @PostMapping("/login/{name}/{pwd}")
+    public boolean login(@PathVariable String name,@PathVariable String pwd){
+        boolean isLogin = false;
+        String userName ="admin";
+        String password="jkadmin123";
+        if((userName).equals(name)&&(password).equals(pwd)){
+            isLogin = true;
+        }
+        return isLogin;
+    }
+}

+ 71 - 0
src/main/java/com/jkcredit/asychronous/controller/ManController.java

@@ -0,0 +1,71 @@
+package com.jkcredit.asychronous.controller;
+
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.Man;
+import com.jkcredit.asychronous.entity.User;
+import com.jkcredit.asychronous.ftp.ManDownloadRoute;
+import com.jkcredit.asychronous.service.ManService;
+import com.jkcredit.asychronous.service.UserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午7:19
+ */
+@Slf4j
+@RestController
+@RequestMapping("man")
+public class ManController {
+
+    @Autowired
+    private ManService manService;
+    @Autowired
+    private UserService userService;
+
+    @PostMapping("receive")
+    public Object receiveMan(@RequestBody Man man) {
+        String requestId = System.currentTimeMillis() + UUID.randomUUID().toString();
+        //判断用户名是否为空
+        if (("").equals(man.getUserName()) || man.getUserName() == null) {
+            return new ResponseEntity(9003, "参数错误", "error", "");
+        }
+        //判断被查询人姓名是否为空
+        if (("").equals(man.getName()) || man.getName() == null) {
+            return new ResponseEntity(9003, "参数错误", "error", "");
+        }
+        if (("").equals(man.getIdCard()) || man.getIdCard() == null) {
+            return new ResponseEntity(9003, "参数错误", "error", "");
+        }
+        if (("").equals(man.getCallBlackUrl()) || man.getCallBlackUrl() == null) {
+            return new ResponseEntity(9003, "参数错误", "error", "");
+        }
+        //查询用户
+        List<User> users = userService.selectByUserName(man.getUserName().trim());
+        //判断查询结果是否为空
+        if (users == null) {
+            return new ResponseEntity(9001, "非法用户", "error", "");
+        }
+        for (User user : users) {
+            //判断用户是否有改接口的接口权限
+            if (!"MAN_CHECK".equals(user.getApi())) {
+                return new ResponseEntity(9002, "接口未授权", "error", "");
+            } else {
+                //如果有权限 将数据添加到数据库 等待文件生产
+                man.setTime(System.currentTimeMillis());
+                man.setRequestId(requestId);
+                manService.insert(man);
+                log.info("插入成功:{}", man);
+                return new ResponseEntity(1000, "请求成功", "success", requestId);
+            }
+        }
+        return new ResponseEntity(9004, "接口错误", "error", "");
+    }
+
+
+}

+ 38 - 0
src/main/java/com/jkcredit/asychronous/controller/UserController.java

@@ -0,0 +1,38 @@
+package com.jkcredit.asychronous.controller;
+
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.User;
+import com.jkcredit.asychronous.service.UserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@RestController
+@RequestMapping("user")
+public class UserController {
+
+    @Autowired
+    private UserService userService;
+
+    @PostMapping("save")
+    public ResponseEntity saveUser(@RequestBody User user){
+        userService.save(user);
+        return new ResponseEntity(200,"插入成功",user);
+    }
+
+    @PostMapping("findAll")
+    public ResponseEntity selectAllUser(){
+        List<User> userList = userService.selectAllUser();
+        return new ResponseEntity(200,"查询成功",userList);
+    }
+
+    @PostMapping("find/{name}")
+    public ResponseEntity findByName(@PathVariable String name){
+        List<User> userList = userService.selectByUserName(name);
+        return new ResponseEntity(200,"查询成功",userList);
+    }
+
+}

+ 25 - 0
src/main/java/com/jkcredit/asychronous/dao/CarRepository.java

@@ -0,0 +1,25 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.Car;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.Query;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午4:14
+ */
+public interface CarRepository extends MongoRepository<Car, Long> {
+
+    /**
+     * 根据开始结束时间查询数据
+     * @param beginTime 开始时间
+     * @param endTime 结束时间
+     * @return 返回车辆list
+     */
+    @Query(value = "{" + "time:{$gte:?0,$lte:?1}\n" + "}")
+    List<Car> selectByTime(Long beginTime, Long endTime);
+
+}

+ 13 - 0
src/main/java/com/jkcredit/asychronous/dao/CarResultRepository.java

@@ -0,0 +1,13 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.CarResult;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:12
+ */
+public interface CarResultRepository extends MongoRepository<CarResult, Long> {
+
+}

+ 65 - 0
src/main/java/com/jkcredit/asychronous/dao/ChargeRepository.java

@@ -0,0 +1,65 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.Charge;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.repository.CountQuery;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.Query;
+
+import java.util.List;
+
+public interface ChargeRepository extends MongoRepository<Charge, Long> {
+
+    /**
+     * 查找计费记录
+     * @param userName 用户名
+     * @param api api名称
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param isCharge 是否计费
+     * @return 返回查询列表
+     */
+    @Query(value = "{" +
+            "    userName:?0,\n" +
+            "    api:?1,\n" +
+            "    time:{$gt:?2,$lt:?3},\n" +
+            "    isCharge:?4\n" +
+            "}")
+    List<Charge> findByUserAndTime(String userName, String api, Long startTime, Long endTime,Integer isCharge);
+
+    /**
+     * 条件查询计费条数
+     * @param userName 用户名
+     * @param api api名称
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param isCharge 是否计费
+     * @return 返回条数
+     */
+    @CountQuery(value = "{" +
+            "    userName:?0,\n" +
+            "    api:?1,\n" +
+            "    time:{$gt:?2,$lt:?3},\n" +
+            "    isCharge:?4\n" +
+            "}")
+    int findCountByUserAndTime(String userName, String api, Long startTime, Long endTime,Integer isCharge);
+
+    /**
+     * 根据api实际查询计费量
+     * @param api api名称
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param isCharge 是否计费
+     * @return 返回条数
+     */
+    @CountQuery(value = "{" +
+            "    api:?0,\n" +
+            "    time:{$gt:?1,$lt:?2},\n" +
+            "    isCharge:?3\n" +
+            "}")
+    int findCountByTime(String api, Long startTime, Long endTime,Integer isCharge);
+
+//    Page<Charge> find(Criteria criteria, Pageable pageable);
+}

+ 25 - 0
src/main/java/com/jkcredit/asychronous/dao/CreditChargeRepository.java

@@ -0,0 +1,25 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.CreditCharge;
+import org.springframework.data.mongodb.repository.CountQuery;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+
+/**
+ * @author sunzhaoning
+ */
+public interface CreditChargeRepository  extends MongoRepository<CreditCharge, Long> {
+
+    /**
+     * 根据时间查询计费量
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param isCharge 是否计费
+     * @return 返回条数
+     */
+    @CountQuery(value = "{" +
+            "    time:{$gt:?0,$lt:?1},\n" +
+            "    isCharge:?2\n" +
+            "}")
+    int findChargeByTime(Long startTime, Long endTime, Integer isCharge);
+}

+ 13 - 0
src/main/java/com/jkcredit/asychronous/dao/ManFtpResultRepository.java

@@ -0,0 +1,13 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.ManFtpResult;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:12
+ */
+public interface ManFtpResultRepository extends MongoRepository<ManFtpResult, Long> {
+
+}

+ 20 - 0
src/main/java/com/jkcredit/asychronous/dao/ManRepository.java

@@ -0,0 +1,20 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.Man;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.Query;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午7:16
+ */
+public interface ManRepository extends MongoRepository<Man, Long> {
+
+    @Query(value = "{" + "time:{$gte:?0,$lte:?1}\n" + "}")
+    List<Man> selectByTime(Long beginTime, Long endTime);
+
+    List<Man> findByIdCard(String idCard);
+}

+ 13 - 0
src/main/java/com/jkcredit/asychronous/dao/ManResultRepository.java

@@ -0,0 +1,13 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.ManResult;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/10/12 上午11:36
+ */
+public interface ManResultRepository extends MongoRepository<ManResult,Long> {
+
+}

+ 20 - 0
src/main/java/com/jkcredit/asychronous/dao/UserRepository.java

@@ -0,0 +1,20 @@
+package com.jkcredit.asychronous.dao;
+
+import com.jkcredit.asychronous.entity.User;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.Query;
+
+import java.util.List;
+
+public interface UserRepository extends MongoRepository<User, Long> {
+
+    List<User> findByUserName(String userName);
+
+
+    @Query(value = "{" +
+            "    userName:{$regex:?0},\n" +
+            "    api:{$regex:?1},\n" +
+            "}")
+    User selectByUserNameAndApi(String userName,String api);
+
+}

+ 31 - 0
src/main/java/com/jkcredit/asychronous/entity/Car.java

@@ -0,0 +1,31 @@
+package com.jkcredit.asychronous.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午2:54
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Car implements Serializable {
+
+    private static final long serialVersionUID = -8808150957066989593L;
+
+    @Excel(name = "customerId")
+    private String customerId;
+    @Excel(name = "name")
+    private String name;
+    @Excel(name = "idCard")
+    private String idCard;
+    @Excel(name = "licencePlate")
+    private String licencePlate;
+    private Long time;
+}

+ 34 - 0
src/main/java/com/jkcredit/asychronous/entity/CarResult.java

@@ -0,0 +1,34 @@
+package com.jkcredit.asychronous.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:02
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CarResult implements Serializable {
+
+    private static final long serialVersionUID = -412999059576184804L;
+
+    @Excel(name = "customerId")
+    private String customerId;
+    @Excel(name = "name")
+    private String name;
+    @Excel(name = "idCard")
+    private String idCard;
+    @Excel(name = "licencePlate")
+    private String licencePlate;
+    @Excel(name = "result")
+    private String result;
+    private Long time = System.currentTimeMillis();
+}

+ 34 - 0
src/main/java/com/jkcredit/asychronous/entity/Charge.java

@@ -0,0 +1,34 @@
+package com.jkcredit.asychronous.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+/**
+ * @Author sunzhaoning
+ */
+public class Charge implements Serializable {
+
+
+    private static final long serialVersionUID = -1071807422059056760L;
+
+    private String userName;
+
+    private Object result;
+
+    private String api;
+
+    private String callBackUrl;
+
+    private Integer code;
+
+    private Integer isCharge;
+
+    private Long time;
+}

+ 35 - 0
src/main/java/com/jkcredit/asychronous/entity/CreditCharge.java

@@ -0,0 +1,35 @@
+package com.jkcredit.asychronous.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author sunzhaoning
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CreditCharge implements Serializable {
+
+    private static final long serialVersionUID = -1071807422059056761L;
+
+    private String customerName;
+
+    private String appKey;
+
+    private int isCharge;
+
+    private String requestId;
+
+    private String result;
+
+    private String api;
+
+    private String souce;
+
+    private Long time;
+
+}

+ 49 - 0
src/main/java/com/jkcredit/asychronous/entity/Man.java

@@ -0,0 +1,49 @@
+package com.jkcredit.asychronous.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Descirption 公安不良接口传入参数
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午2:52
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Man implements Serializable {
+
+    private static final long serialVersionUID = 5030089667135944911L;
+
+    /**
+     * 用户
+     */
+    private String userName;
+
+    /**
+     * 姓名
+     */
+    @Excel(name = "name")
+    private String name;
+
+    /**
+     * 身份证号码
+     */
+    @Excel(name = "idCard")
+    private String idCard;
+
+    /**
+     * 客户传入回调地址
+     */
+    private String callBlackUrl;
+    /**
+     * 时间
+     */
+    private Long time;
+
+    private String requestId;
+}

+ 59 - 0
src/main/java/com/jkcredit/asychronous/entity/ManFtpResult.java

@@ -0,0 +1,59 @@
+package com.jkcredit.asychronous.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Descirption 公安不良FTP返回实体类
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:02
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ManFtpResult implements Serializable {
+
+    private static final long serialVersionUID = 6989516301338504002L;
+
+    /**
+     * 姓名
+     */
+    private String name;
+
+    /**
+     * 身份证号
+     */
+    //@Excel(name = "idCard", orderNum = "1")
+    private String idCard;
+
+    /**
+     * 身份证一致不一致
+     */
+    //@Excel(name = "isIdCard", orderNum = "2")
+    private String isIdCard;
+
+    /**
+     * 是否在逃
+     */
+//    @Excel(name = "isEscape", orderNum = "3")
+    private String isEscape;
+
+    /**
+     * 是否有前科
+     */
+//    @Excel(name = "isPedigree", orderNum = "4")
+    private String isPedigree;
+
+    /**
+     * 是否吸毒贩毒
+     */
+//    @Excel(name = "isDrugs", orderNum = "5")
+    private String isDrugs;
+
+    private Long time = System.currentTimeMillis();
+
+}

+ 77 - 0
src/main/java/com/jkcredit/asychronous/entity/ManResult.java

@@ -0,0 +1,77 @@
+package com.jkcredit.asychronous.entity;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Descirption 公安不良回调实体
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/10/12 上午11:28
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ManResult implements Serializable {
+
+    private static final long serialVersionUID = 6989516301338504012L;
+
+    /**
+     * 客户编号
+     */
+    private String userName;
+
+    /**
+     * 身份号
+     */
+    private String idCard;
+
+    /**
+     * 姓名
+     */
+    private String name;
+
+    /**
+     * 身份证一致不一致
+     */
+    private Integer isIdCard;
+
+    /**
+     * 是否在逃
+     */
+    private Integer isEscape;
+
+    /**
+     * 是否有前科
+     */
+    private Integer isPedigree;
+
+    /**
+     * 是否吸毒贩毒
+     */
+    private Integer isDrugs;
+
+    /**
+     * 返回状态码
+     */
+    private Integer resultCode;
+
+    /**
+     * 客户传入回调地址
+     */
+    private String callBlackUrl;
+
+    /**
+     * 批次
+     */
+    private String batch;
+
+    /**
+     * 流水号
+     */
+    private String requestId;
+
+}

+ 21 - 0
src/main/java/com/jkcredit/asychronous/entity/User.java

@@ -0,0 +1,21 @@
+package com.jkcredit.asychronous.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class User implements Serializable {
+
+    private static final long serialVersionUID = 7571231284666660L;
+
+    private String userName;
+
+    private String api;
+
+    private String companyName;
+}

+ 48 - 0
src/main/java/com/jkcredit/asychronous/ftp/CarDownloadRoute.java

@@ -0,0 +1,48 @@
+package com.jkcredit.asychronous.ftp;
+
+import com.jkcredit.asychronous.process.CarLocationFileProcessor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 上午11:49
+ */
+@Slf4j
+@Component
+public class CarDownloadRoute extends RouteBuilder {
+
+    @Value("${carftp.download.ftp}")
+    private String sftpServer;
+    @Value("${carftp.download.dir}")
+    private String downloadLocation;
+
+    @Autowired
+    private CarLocationFileProcessor carLocationFileProcessor;
+
+    @Override
+    public void configure() throws Exception {
+        downRoute();
+        parseRoute();
+    }
+
+    /**
+     * 下载路由
+     */
+    private void downRoute() {
+        from(sftpServer).to(downloadLocation).log(LoggingLevel.INFO, log, "Downloaded CarFile ${file:name} complete.");
+    }
+
+    /**
+     * 解析路由
+     */
+    private void parseRoute() {
+        from(downloadLocation).process(carLocationFileProcessor).log(LoggingLevel.INFO, log, "Read CarFile ${file:name} complete.");
+
+    }
+}

+ 48 - 0
src/main/java/com/jkcredit/asychronous/ftp/ManDownloadRoute.java

@@ -0,0 +1,48 @@
+package com.jkcredit.asychronous.ftp;
+
+import com.jkcredit.asychronous.process.ManLocationFileProcessor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 上午11:49
+ */
+@Slf4j
+@Component
+public class ManDownloadRoute extends RouteBuilder {
+
+    @Value("${manftp.download.ftp}")
+    private String sftpServer;
+    @Value("${manftp.download.dir}")
+    private String downloadLocation;
+
+    @Autowired
+    private ManLocationFileProcessor manLocationFileProcessor;
+
+    @Override
+    public void configure() {
+        downRoute();
+        parseRoute();
+    }
+
+    /**
+     * 下载路由
+     */
+    private void downRoute() {
+        from(sftpServer).to(downloadLocation).log(LoggingLevel.INFO, log, "Downloaded ManFile ${file:name} complete.");
+    }
+
+    /**
+     * 解析路由
+     */
+    private void parseRoute() {
+        from(downloadLocation).process(manLocationFileProcessor).log(LoggingLevel.INFO, log, "Read ManFile ${file:name} complete.");
+
+    }
+}

+ 54 - 0
src/main/java/com/jkcredit/asychronous/job/CarJob.java

@@ -0,0 +1,54 @@
+package com.jkcredit.asychronous.job;
+
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.Car;
+import com.jkcredit.asychronous.service.CarService;
+import com.jkcredit.asychronous.util.ExcelUtil;
+import com.jkcredit.asychronous.util.FtpUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午6:01
+ */
+@Component
+@Slf4j
+public class CarJob {
+
+    @Value("${carftp.upload.local}")
+    private String localDir;
+    @Value("${ftp.host}")
+    private String host;
+    @Value("${ftp.port}")
+    private Integer port;
+    @Value("${ftp.username}")
+    private String userName;
+    @Value("${ftp.password}")
+    private String passWord;
+    @Value("${ftp.dir.car}")
+    private String dir;
+
+    @Autowired
+    private CarService carService;
+
+//    @Scheduled(cron = "0 0/2 * * * ?")
+    public void car() {
+        List<Car> list = carService.selectByTime();
+        if (list.size() > 0) {
+            log.info("开始 车辆信息excel 导出");
+//            String fileName = ExcelUtil.export(list, Car.class, localDir);
+//            log.info("CarExcel:{}", fileName);
+//            FtpUtil.fileUpload(host, port, userName, passWord, dir, fileName);
+        } else {
+            log.error("error:{}", new ResponseEntity(400, "车辆信息未查到", ""));
+        }
+
+    }
+}

+ 111 - 0
src/main/java/com/jkcredit/asychronous/job/ManJob.java

@@ -0,0 +1,111 @@
+package com.jkcredit.asychronous.job;
+
+import com.alibaba.fastjson.JSONArray;
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.Man;
+import com.jkcredit.asychronous.service.ManService;
+import com.jkcredit.asychronous.util.ExcelUtil;
+import com.jkcredit.asychronous.util.FtpUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午7:34
+ */
+@Slf4j
+@Component
+public class ManJob {
+
+    @Value("${manftp.upload.local}")
+    private String localDir;
+    @Value("${ftp.host}")
+    private String host;
+    @Value("${ftp.port}")
+    private Integer port;
+    @Value("${ftp.username}")
+    private String userName;
+    @Value("${ftp.password}")
+    private String passWord;
+    @Value("${ftp.dir.man}")
+    private String dir;
+
+    @Autowired
+    private ManService manService;
+
+    @Scheduled(cron = "0/10 * * * * ?")
+    public void car() {
+        Long beginTime= System.currentTimeMillis() - 10000;
+        Long endTime = System.currentTimeMillis();
+        List<Man> list = manService.selectByTime(beginTime,endTime);
+//        log.info("开始 公安不良excel 导出");
+        if (list.size() > 0) {
+            JSONArray ja = new JSONArray();
+            for(Man man : list){
+                ja.add(man);
+            }
+            Map<String,String> headMap = new LinkedHashMap<>();
+            headMap.put("name","姓名");
+            headMap.put("idCard","身份证号");
+            String fileName = localDir + File.separator + endTime.toString() + ".xlsx";
+
+            try {
+                OutputStream outXlsx = new FileOutputStream(fileName);
+                ExcelUtil.exportExcelX(headMap,ja,null,0,outXlsx);
+                outXlsx.close();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+//            String fileName = ExcelUtil.export(list, Man.class, localDir,endTime.toString());
+//            log.info("ManExcel:{}", fileName);
+            FtpUtil.fileUpload(host, port, userName, passWord, dir, fileName);
+        }
+//        else {
+//            log.error("error:{}1", new ResponseEntity(400, "公安不良信息未查到", ""));
+//        }
+
+    }
+
+    //@Scheduled(cron = "0 0/30 * * * ?")
+    public void test(){
+
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
+
+        List<Man> list = new ArrayList<>();
+        Man mantest = new Man();
+        mantest.setIdCard("420581198402220816");
+        mantest.setName("徐建华");
+        list.add(mantest);
+        JSONArray ja = new JSONArray();
+        for(Man man : list){
+            ja.add(man);
+        }
+        Map<String,String> headMap = new LinkedHashMap<>();
+        headMap.put("name","姓名");
+        headMap.put("idCard","身份证号");
+        String fileName = localDir + File.separator + df.format(new Date()) + ".xlsx";
+
+        try {
+            OutputStream outXlsx = new FileOutputStream(fileName);
+            ExcelUtil.exportExcelX(headMap,ja,null,0,outXlsx);
+            outXlsx.close();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+//            String fileName = ExcelUtil.export(list, Man.class, localDir,endTime.toString());
+//            log.info("ManExcel:{}", fileName);
+        FtpUtil.fileUpload(host, port, userName, passWord, dir, fileName);
+    }
+}

+ 52 - 0
src/main/java/com/jkcredit/asychronous/mq/RabbitMqReceiver.java

@@ -0,0 +1,52 @@
+package com.jkcredit.asychronous.mq;
+
+import com.jkcredit.asychronous.entity.CreditCharge;
+import com.jkcredit.asychronous.service.CreditChargeService;
+import com.rabbitmq.client.Channel;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * @author sunzhaoning
+ */
+@Component
+public class RabbitMqReceiver {
+
+    @Autowired
+    private CreditChargeService creditChargeService;
+    @RabbitListener(queues = {"marriage"})
+    public void process(Channel channel, Message message) {
+        try {
+            //告诉服务器收到这条消息 已经被我消费了 可以在队列删掉 这样以后就不会再发了 否则消息服务器以为这条消息没处理掉 后续还会在发
+            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+            String [] result = new String(message.getBody()).split("\\|");
+
+            CreditCharge creditCharge = new CreditCharge();
+            creditCharge.setCustomerName(result[0]);
+            creditCharge.setAppKey(result[1]);
+            creditCharge.setIsCharge(changeInt(result[2]));
+            creditCharge.setRequestId(result[3]);
+            creditCharge.setResult(result[4]);
+            creditCharge.setApi(result[5]);
+            creditCharge.setSouce(result[6]);
+            creditCharge.setTime(Long.parseLong(result[7]));
+            creditChargeService.insert(creditCharge);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+    public Integer changeInt(String isCharge){
+        Integer charge= 0;
+        String rs = "true";
+        if((rs).equals(isCharge)){
+            charge=1;
+        }
+        return charge;
+    }
+}

+ 78 - 0
src/main/java/com/jkcredit/asychronous/process/CarLocationFileProcessor.java

@@ -0,0 +1,78 @@
+package com.jkcredit.asychronous.process;
+
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.CarResult;
+import com.jkcredit.asychronous.service.CarResultService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.file.GenericFileMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.*;
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午1:20
+ */
+@Component
+@Slf4j
+public class CarLocationFileProcessor implements Processor {
+
+    @Value("${carftp.download.info}")
+    private String fileDir;
+//    @Value("${callback.url}")
+    private String url;
+
+    @Autowired
+    private CarResultService carResultService;
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    public void process(Exchange exchange) {
+        exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+        GenericFileMessage<RandomAccessFile> inFileMessage = (GenericFileMessage<RandomAccessFile>) exchange.getIn();
+        String fileName = inFileMessage.getGenericFile().getFileName();//文件名
+        String splitTag = File.separator;//系统文件分隔符
+        log.info(fileDir + splitTag + fileName);//文件的绝对路径
+
+        List<CarResult> carlList = readExcel(fileDir + splitTag + fileName);
+        if (carlList.size() > 0) {
+            log.info("读取成功");
+            carResultService.insert(carlList);
+            log.info("入库成功");
+            MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
+            paramMap.add("data", new ResponseEntity(carlList, "car"));
+            HttpHeaders headers = new HttpHeaders();
+            HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(paramMap, headers);
+            restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
+        } else {
+            log.error("error", new ResponseEntity(400, "读取文件为空", ""));
+        }
+
+    }
+
+    // 去读Excel的方法readExcel,该方法的入口参数为一个File对象
+    public List<CarResult> readExcel(String file) {
+        ImportParams params = new ImportParams();
+        params.setHeadRows(1);
+        List<CarResult> list = ExcelImportUtil.importExcel(
+                new File(file),
+                CarResult.class, params);
+        return list;
+    }
+
+}

+ 224 - 0
src/main/java/com/jkcredit/asychronous/process/ManLocationFileProcessor.java

@@ -0,0 +1,224 @@
+package com.jkcredit.asychronous.process;
+
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
+import com.alibaba.fastjson.JSONObject;
+import com.jkcredit.asychronous.common.ResponseEntity;
+import com.jkcredit.asychronous.entity.Charge;
+import com.jkcredit.asychronous.entity.Man;
+import com.jkcredit.asychronous.entity.ManFtpResult;
+import com.jkcredit.asychronous.entity.ManResult;
+import com.jkcredit.asychronous.service.ChargeService;
+import com.jkcredit.asychronous.service.ManFtpResultService;
+import com.jkcredit.asychronous.service.ManResultService;
+import com.jkcredit.asychronous.service.ManService;
+import com.jkcredit.asychronous.util.ExcelUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.file.GenericFileMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import org.springframework.http.HttpEntity;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.stereotype.Component;
+
+import org.springframework.web.client.RestTemplate;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午7:46
+ */
+@Slf4j
+@Component
+public class ManLocationFileProcessor implements Processor {
+
+    @Value("${manftp.download.info}")
+    private String fileDir;
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private ManResultService manResultService;
+
+    @Autowired
+    private ManService manService;
+
+    @Autowired
+    private ChargeService chargeService;
+
+    @Autowired
+    private ManFtpResultService manFtpResultService;
+
+    @Override
+    public void process(Exchange exchange) {
+        exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+        GenericFileMessage<RandomAccessFile> inFileMessage = (GenericFileMessage<RandomAccessFile>) exchange.getIn();
+        //文件名
+        String fileName = inFileMessage.getGenericFile().getFileName();
+        //系统文件分隔符
+        String splitTag = File.separator;
+        //文件的绝对路径
+        log.info(fileDir + splitTag + fileName);
+
+        Charge charge = new Charge();
+
+        List<ManResult> manResultList = new ArrayList<>();
+        //文件读取完返回结果
+        List<ManFtpResult> manFtpResultList = ExcelUtil.readExcel(fileDir + splitTag + fileName);
+        if (manFtpResultList.size() > 0) {
+            manFtpResultService.insert(manFtpResultList);
+            //根据文件名称获取时间
+            String[] beforStr = fileName.split("_");
+            String[] str = beforStr[1].split("\\.");
+            fileName = str[0];
+            Long beginTime = Long.parseLong(fileName) - 10000;
+            Long endTime = Long.parseLong(fileName);
+            //查询时间段内的数据
+            List<Man> manList = manService.selectByTime(beginTime, endTime);
+            //查询传入数据并返回数据
+
+            ManResult manResult;
+            for (Man man : manList) {
+                //从数据库查询的结果跟 excel结果进行比对
+                manResult = new ManResult();
+                String userName = man.getUserName();
+                String name = man.getName();
+                String idCard = man.getIdCard();
+                String requestId = man.getRequestId();
+
+                manResult.setName(name);
+                manResult.setUserName(userName);
+                manResult.setIdCard(idCard);
+                manResult.setRequestId(requestId);
+
+                //查询失败 设置1001
+                manResult.setResultCode(1001);
+                manResult.setCallBlackUrl(man.getCallBlackUrl());
+
+
+                for (ManFtpResult manFtpResult : manFtpResultList) {
+
+                    //如果身份证号码一致设置参数
+                    if (man.getIdCard().equals(manFtpResult.getIdCard()) && man.getName().equals(manFtpResult.getName())) {
+
+                        String isIdCard = manFtpResult.getIsIdCard();
+                        String isDrugs = manFtpResult.getIsDrugs();
+                        String isEcape = manFtpResult.getIsEscape();
+                        String isPedigree = manFtpResult.getIsPedigree();
+                        manResult.setResultCode(1000);
+
+                        //判断返回码是否为2 如果是2 设置状态码1002 不计费
+                        if (("2").equals(isIdCard)) {
+                            manResult.setResultCode(1002);
+                        }
+                        if (("2").equals(isDrugs)) {
+                            manResult.setResultCode(1002);
+                        }
+                        if (("2").equals(isEcape)) {
+                            manResult.setResultCode(1002);
+                        }
+                        if (("2").equals(isPedigree)) {
+                            manResult.setResultCode(1002);
+                        }
+
+                        name = manFtpResult.getName();
+                        manResult.setName(name);
+                        manResult.setUserName(userName);
+                        manResult.setIdCard(idCard);
+                        manResult.setIsIdCard(stringForInt(isIdCard));
+                        manResult.setIsEscape(stringForInt(isEcape));
+                        manResult.setIsDrugs(stringForInt(isDrugs));
+                        manResult.setIsPedigree(stringForInt(isPedigree));
+                        //查询是成功设置1000
+
+                    }
+
+                }
+                //设置返回批次
+                manResult.setBatch(fileName);
+                manResultList.add(manResult);
+
+            }
+            /**
+             * 将返回结果返回给回调地址
+             */
+            if (manResultList.size() > 0) {
+                manResultList.forEach(manResults -> {
+                    //发送请求给回调地址
+                    try {
+
+                        HttpEntity httpEntity = restTemplate.postForEntity(manResults.getCallBlackUrl(), manResults,
+                                String.class);
+                        int stateCode = 200;
+                        if (((org.springframework.http.ResponseEntity) httpEntity).getStatusCodeValue() == stateCode) {
+                            charge.setUserName(manResults.getUserName());
+                            charge.setApi("MAN_CHECK");
+                            charge.setCode(manResults.getResultCode());
+                            charge.setIsCharge(1);
+                            charge.setCallBackUrl(manResults.getCallBlackUrl());
+                            charge.setResult(manResults);
+                            charge.setTime(System.currentTimeMillis());
+
+                            String json = JSONObject.toJSONString(charge);
+                            log.info(json);
+                            chargeService.insert(charge);
+                        }
+                    } catch (Exception e) {
+                        charge.setUserName(manResults.getUserName());
+                        charge.setApi("MAN_CHECK");
+                        charge.setCode(manResults.getResultCode());
+                        charge.setIsCharge(1);
+                        charge.setCallBackUrl(manResults.getCallBlackUrl());
+                        charge.setResult(manResults);
+                        charge.setTime(System.currentTimeMillis());
+                        String json = JSONObject.toJSONString(charge);
+                        log.info(json);
+                        chargeService.insert(charge);
+                        log.error("回调地址不通:{}", manResults.getCallBlackUrl());
+                    }
+
+
+                });
+                manResultService.insert(manResultList);
+            } else {
+                log.error("error:{}", new ResponseEntity(400, "无结果", "erro", ""));
+            }
+        } else {
+            log.error("error:{}", new ResponseEntity(401, "读取文件内容为空", "erro", ""));
+        }
+
+
+    }
+
+    /**
+     * 去读Excel的方法readExcel,该方法入口参数为一个Filedir
+     *
+     * @param file
+     * @return
+     */
+    public List<ManFtpResult> readExcel(String file) {
+        ImportParams params = new ImportParams();
+        params.setHeadRows(0);
+        List<ManFtpResult> list = ExcelImportUtil.importExcel(
+                new File(file), ManFtpResult.class, params);
+        return list;
+    }
+
+    public Integer stringForInt(String str) {
+        return Integer.parseInt(str.substring(0, 1));
+    }
+
+    public static void main(String[] args) {
+
+    }
+
+}

+ 19 - 0
src/main/java/com/jkcredit/asychronous/service/CarResultService.java

@@ -0,0 +1,19 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.CarResult;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:15
+ */
+public interface CarResultService {
+
+    /**
+     * 新增车辆信息
+     * @param carResult 车辆列表
+     */
+    void insert(List<CarResult> carResult);
+}

+ 17 - 0
src/main/java/com/jkcredit/asychronous/service/CarService.java

@@ -0,0 +1,17 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.Car;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午8:09
+ */
+public interface CarService {
+
+    List<Car> selectByTime();
+
+    void insert(Car car);
+}

+ 22 - 0
src/main/java/com/jkcredit/asychronous/service/ChargeService.java

@@ -0,0 +1,22 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.Charge;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+public interface ChargeService {
+
+    void insert(Charge charge);
+
+    List<Charge> findByUserAndTime(String userName, String api, Long startTime, Long endTime);
+
+    int findCountByUserAndTime(String userName, String api, Long startTime, Long endTime);
+
+    Page<Charge> page(String userName, String api, Long startTime, Long endTime, Pageable pageable);
+
+    int findCountByTime(String api, Long startTime, Long endTime);
+
+
+}

+ 14 - 0
src/main/java/com/jkcredit/asychronous/service/CreditChargeService.java

@@ -0,0 +1,14 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.CreditCharge;
+
+/**
+ * @author sunzhaoning
+ */
+public interface CreditChargeService {
+
+    void insert(CreditCharge charge);
+
+    int findChargeByTime(Long startTime, Long endTime);
+
+}

+ 15 - 0
src/main/java/com/jkcredit/asychronous/service/ManFtpResultService.java

@@ -0,0 +1,15 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.ManFtpResult;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:15
+ */
+public interface ManFtpResultService {
+
+    void insert(List<ManFtpResult> manFtpResult);
+}

+ 15 - 0
src/main/java/com/jkcredit/asychronous/service/ManResultService.java

@@ -0,0 +1,15 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.ManResult;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/10/12 上午11:40
+ */
+public interface ManResultService {
+
+    void insert(List<ManResult> manResult);
+}

+ 20 - 0
src/main/java/com/jkcredit/asychronous/service/ManService.java

@@ -0,0 +1,20 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.Man;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午8:10
+ */
+public interface ManService {
+
+    List<Man> selectByTime(Long beginTime,Long endTime);
+
+    void insert(Man man);
+
+    List<Man> selectByIdCard(String idCard);
+
+}

+ 35 - 0
src/main/java/com/jkcredit/asychronous/service/UserService.java

@@ -0,0 +1,35 @@
+package com.jkcredit.asychronous.service;
+
+import com.jkcredit.asychronous.entity.User;
+
+import java.util.List;
+
+public interface UserService {
+
+    /**
+     * 根据用户名查询用户信息
+     * @param userName
+     * @return
+     */
+    List<User> selectByUserName(String userName);
+
+    /**
+     * 查询所有用户
+     * @return
+     */
+    List<User> selectAllUser();
+
+    /**
+     * 根据用户名和API查询用户是否有接口权限
+     * @param userName
+     * @param api
+     * @return
+     */
+    User selectByUserNameAndApi(String userName,String api);
+
+    /**
+     * 新增用户权限
+     * @param user
+     */
+    void save(User user);
+}

+ 26 - 0
src/main/java/com/jkcredit/asychronous/service/impl/CarResultServiceImpl.java

@@ -0,0 +1,26 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.CarResultRepository;
+import com.jkcredit.asychronous.entity.CarResult;
+import com.jkcredit.asychronous.service.CarResultService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:24
+ */
+@Service("carResultService")
+public class CarResultServiceImpl implements CarResultService {
+
+    @Autowired
+    private CarResultRepository carResultRepository;
+
+    @Override
+    public void insert(List<CarResult> carResult) {
+        carResultRepository.insert(carResult);
+    }
+}

+ 33 - 0
src/main/java/com/jkcredit/asychronous/service/impl/CarServiceImpl.java

@@ -0,0 +1,33 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.CarRepository;
+import com.jkcredit.asychronous.entity.Car;
+import com.jkcredit.asychronous.service.CarService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午8:11
+ */
+@Service("carService")
+public class CarServiceImpl implements CarService {
+
+    @Autowired
+    private CarRepository carRepository;
+
+    @Override
+    public List<Car> selectByTime() {
+        Long beginTime = System.currentTimeMillis() - 600000;
+        Long endTime = System.currentTimeMillis();
+        return carRepository.selectByTime(beginTime, endTime);
+    }
+
+    @Override
+    public void insert(Car car) {
+        carRepository.insert(car);
+    }
+}

+ 51 - 0
src/main/java/com/jkcredit/asychronous/service/impl/ChargeServiceImpl.java

@@ -0,0 +1,51 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.ChargeRepository;
+import com.jkcredit.asychronous.entity.Charge;
+import com.jkcredit.asychronous.service.ChargeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author sunzhaoning
+ */
+@Service("chargeService")
+public class ChargeServiceImpl implements ChargeService {
+
+    @Autowired
+    private ChargeRepository chargeRepository;
+
+    @Override
+    public void insert(Charge charge) {
+        chargeRepository.insert(charge);
+    }
+
+    @Override
+    public List<Charge> findByUserAndTime(String userName, String api, Long startTime, Long endTime) {
+        return chargeRepository.findByUserAndTime(userName,api,startTime,endTime,1);
+    }
+
+    @Override
+    public int findCountByUserAndTime(String userName, String api, Long startTime, Long endTime) {
+        return chargeRepository.findCountByUserAndTime(userName,api,startTime,endTime,1);
+    }
+
+    @Override
+    public Page<Charge> page(String userName, String api, Long startTime, Long endTime, Pageable pageable) {
+        final long total= chargeRepository.findCountByUserAndTime(userName,api,startTime,endTime,1);
+        final List<Charge> list = chargeRepository.findByUserAndTime(userName,api,startTime,endTime,1);
+        return new PageImpl(list, pageable, total);
+    }
+
+    @Override
+    public int findCountByTime(String api, Long startTime, Long endTime) {
+        return chargeRepository.findCountByTime(api,startTime,endTime,1);
+    }
+
+}

+ 27 - 0
src/main/java/com/jkcredit/asychronous/service/impl/CreditChargeServiceImpl.java

@@ -0,0 +1,27 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.CreditChargeRepository;
+import com.jkcredit.asychronous.entity.CreditCharge;
+import com.jkcredit.asychronous.service.CreditChargeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author sunzhaoning
+ */
+@Service
+public class CreditChargeServiceImpl implements CreditChargeService {
+
+    @Autowired
+    private CreditChargeRepository creditChargeRepository;
+
+    @Override
+    public void insert(CreditCharge charge) {
+        creditChargeRepository.insert(charge);
+    }
+
+    @Override
+    public int findChargeByTime(Long startTime, Long endTime) {
+        return creditChargeRepository.findChargeByTime(startTime,endTime,1);
+    }
+}

+ 26 - 0
src/main/java/com/jkcredit/asychronous/service/impl/ManFtpResultServiceImpl.java

@@ -0,0 +1,26 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.ManFtpResultRepository;
+import com.jkcredit.asychronous.entity.ManFtpResult;
+import com.jkcredit.asychronous.service.ManFtpResultService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/23 上午9:16
+ */
+@Service("manFtpResultService")
+public class ManFtpResultServiceImpl implements ManFtpResultService {
+
+    @Autowired
+    private ManFtpResultRepository manResultRepository;
+
+    @Override
+    public void insert(List<ManFtpResult> manFtpResult) {
+        manResultRepository.insert(manFtpResult);
+    }
+}

+ 26 - 0
src/main/java/com/jkcredit/asychronous/service/impl/ManResultServiceImpl.java

@@ -0,0 +1,26 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.ManResultRepository;
+import com.jkcredit.asychronous.entity.ManResult;
+import com.jkcredit.asychronous.service.ManResultService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/10/12 上午11:46
+ */
+@Service("manResultService")
+public class ManResultServiceImpl  implements ManResultService {
+
+    @Autowired
+    private ManResultRepository manResultRepository;
+
+    @Override
+    public void insert(List<ManResult> manResult) {
+        manResultRepository.insert(manResult);
+    }
+}

+ 36 - 0
src/main/java/com/jkcredit/asychronous/service/impl/ManServiceImpl.java

@@ -0,0 +1,36 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.ManRepository;
+import com.jkcredit.asychronous.entity.Man;
+import com.jkcredit.asychronous.service.ManService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午8:15
+ */
+@Service("manService")
+public class ManServiceImpl implements ManService {
+
+    @Autowired
+    private ManRepository manRepository;
+
+    @Override
+    public List<Man> selectByTime(Long beginTime,Long endTime) {
+        return manRepository.selectByTime(beginTime, endTime);
+    }
+
+    @Override
+    public void insert(Man man) {
+        manRepository.insert(man);
+    }
+
+    @Override
+    public List<Man> selectByIdCard(String idCard) {
+        return manRepository.findByIdCard(idCard);
+    }
+}

+ 36 - 0
src/main/java/com/jkcredit/asychronous/service/impl/UserServiceImpl.java

@@ -0,0 +1,36 @@
+package com.jkcredit.asychronous.service.impl;
+
+import com.jkcredit.asychronous.dao.UserRepository;
+import com.jkcredit.asychronous.entity.User;
+import com.jkcredit.asychronous.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service("userService")
+public class UserServiceImpl implements UserService {
+
+    @Autowired
+    private UserRepository userRepository;
+
+    @Override
+    public List<User> selectByUserName(String userName) {
+        return userRepository.findByUserName(userName);
+    }
+
+    @Override
+    public List<User> selectAllUser() {
+        return userRepository.findAll();
+    }
+
+    @Override
+    public User selectByUserNameAndApi(String userName, String api) {
+        return userRepository.selectByUserNameAndApi(userName,api);
+    }
+
+    @Override
+    public void save(User user) {
+        userRepository.save(user);
+    }
+}

+ 325 - 0
src/main/java/com/jkcredit/asychronous/util/ExcelUtil.java

@@ -0,0 +1,325 @@
+package com.jkcredit.asychronous.util;
+
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jkcredit.asychronous.entity.Car;
+import com.jkcredit.asychronous.entity.ManFtpResult;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFCell;
+import org.apache.poi.xssf.streaming.SXSSFRow;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static javax.print.attribute.standard.JobState.PROCESSING;
+import static javax.xml.bind.JAXBIntrospector.getValue;
+
+/**
+ * @Descirption
+ * @Author Zhaoning Sun
+ * @Date Created in 2018/6/22 下午5:53
+ */
+public class ExcelUtil {
+
+
+    /**
+     * suffix of excel 2003
+     */
+    public static final String OFFICE_EXCEL_V2003_SUFFIX = "xls";
+    /**
+     * suffix of excel 2007
+     */
+    public static final String OFFICE_EXCEL_V2007_SUFFIX = "xlsx";
+    /**
+     * suffix of excel 2010
+     */
+    public static final String OFFICE_EXCEL_V2010_SUFFIX = "xlsx";
+
+    public static final String NOT_EXCEL_FILE = " is Not a Excel file!";
+
+    public static final String EMPTY = "";
+    public static final String DOT = ".";
+
+    public static String NO_DEFINE = "no_define";//未定义的字段
+    public static String DEFAULT_DATE_PATTERN="yyyy年MM月dd日";//默认日期格式
+    public static int DEFAULT_COLOUMN_WIDTH = 17;
+
+
+    public static <T> String export(List<T> list, Class<T> clazz, String pathName,String time) {
+        File savefile = new File(pathName);
+        if (!savefile.exists()) {
+            savefile.mkdirs();
+        }
+
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(),
+                clazz, list);
+        FileOutputStream fos;
+        try {
+
+            String fileName = pathName + File.separator + time + ".xls";
+            fos = new FileOutputStream(fileName);
+            workbook.write(fos);
+            fos.close();
+            return fileName;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    public static List<ManFtpResult> readExcel(String path) {
+        if (StringUtils.isBlank(path)) {
+            throw new IllegalArgumentException(path + " excel file path is either null or empty");
+        } else {
+            String suffiex = getSuffiex(path);
+            if(StringUtils.isBlank(suffiex)){
+                throw new IllegalArgumentException(path + " suffiex is either null or empty");
+            }
+            if (OFFICE_EXCEL_V2003_SUFFIX.equals(suffiex)) {
+                return readXls(path);
+            } else if (OFFICE_EXCEL_V2007_SUFFIX.equals(suffiex)) {
+                return readXlsx(path);
+            } else if (OFFICE_EXCEL_V2010_SUFFIX.equals(suffiex)) {
+                return readXlsx(path);
+            } else {
+                throw new IllegalArgumentException(path + NOT_EXCEL_FILE);
+            }
+        }
+    }
+
+    public static List<ManFtpResult> readXls(String path) {
+
+        InputStream is = null;
+        HSSFWorkbook hssfWorkbook = null;
+        List<ManFtpResult> list = new ArrayList<ManFtpResult>();
+        try {
+            is = new FileInputStream(path);
+            hssfWorkbook= new HSSFWorkbook(is);
+            ManFtpResult manFtpResult = null;
+
+        // Read the Sheet
+        for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
+            HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
+            if (hssfSheet == null) {
+                continue;
+            }
+            // Read the Row
+            for (int rowNum = 0; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                HSSFRow hssfRow = hssfSheet.getRow(rowNum);
+                if (hssfRow != null) {
+                    manFtpResult = new ManFtpResult();
+                    HSSFCell name = hssfRow.getCell(0);
+                    HSSFCell idCard = hssfRow.getCell(1);
+                    HSSFCell isIdCard = hssfRow.getCell(2);
+                    HSSFCell isEscape = hssfRow.getCell(3);
+                    HSSFCell isPedigree = hssfRow.getCell(4);
+                    HSSFCell isDrugs = hssfRow.getCell(5);
+                    manFtpResult.setName(getValue(name).toString());
+                    manFtpResult.setIdCard(getValue(idCard).toString());
+                    manFtpResult.setIsIdCard(getValue(isIdCard).toString());
+                    manFtpResult.setIsEscape(getValue(isEscape).toString());
+                    manFtpResult.setIsPedigree(getValue(isPedigree).toString());
+                    manFtpResult.setIsDrugs(getValue(isDrugs).toString());
+                    list.add(manFtpResult);
+                }
+            }
+        }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return list;
+    }
+
+    public static List<ManFtpResult> readXlsx(String path){
+        InputStream is;
+        XSSFWorkbook xssfWorkbook = null;
+        try {
+            is = new FileInputStream(path);
+            xssfWorkbook = new XSSFWorkbook(is);
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        ManFtpResult manFtpResult = null;
+        List<ManFtpResult> list = new ArrayList<ManFtpResult>();
+        // Read the Sheet
+        for (int numSheet = 0; numSheet < xssfWorkbook.getNumberOfSheets(); numSheet++) {
+            XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(numSheet);
+            if (xssfSheet == null) {
+                continue;
+            }
+            // Read the Row
+            for (int rowNum = 0; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
+                XSSFRow xssfRow = xssfSheet.getRow(rowNum);
+                if (xssfRow != null) {
+                    manFtpResult = new ManFtpResult();
+                    XSSFCell name = xssfRow.getCell(0);
+                    XSSFCell idCard = xssfRow.getCell(1);
+                    XSSFCell isIdCard = xssfRow.getCell(2);
+                    XSSFCell isEscape = xssfRow.getCell(3);
+                    XSSFCell isPedigree = xssfRow.getCell(4);
+                    XSSFCell isDrugs = xssfRow.getCell(5);
+                    manFtpResult.setName(getValue(name).toString());
+                    manFtpResult.setIdCard(getValue(idCard).toString());
+                    manFtpResult.setIsIdCard(getValue(isIdCard).toString());
+                    manFtpResult.setIsEscape(getValue(isEscape).toString());
+                    manFtpResult.setIsPedigree(getValue(isPedigree).toString());
+                    manFtpResult.setIsDrugs(getValue(isDrugs).toString());
+                    list.add(manFtpResult);
+                }
+            }
+        }
+        return list;
+    }
+
+    public static String getSuffiex(String path) {
+        if(StringUtils.isBlank(path)){
+            return EMPTY;
+        }
+        int index = path.lastIndexOf(DOT);
+        if (index == -1) {
+            return EMPTY;
+        }
+        return path.substring(index + 1, path.length());
+    }
+
+    /**
+     * 导出Excel 2007 OOXML (.xlsx)格式
+     * @param headMap 属性-列头
+     * @param jsonArray 数据集
+     * @param datePattern 日期格式,传null值则默认 年月日
+     * @param colWidth 列宽 默认 至少17个字节
+     * @param out 输出流
+     */
+    public static void exportExcelX( Map<String, String> headMap, JSONArray jsonArray, String datePattern,
+                                     int colWidth, OutputStream out) {
+        if (datePattern == null){
+            datePattern = DEFAULT_DATE_PATTERN;
+        }
+        // 声明一个工作薄  缓存
+        SXSSFWorkbook workbook = new SXSSFWorkbook(1000);
+        workbook.setCompressTempFiles(true);
+        //表头样式
+        CellStyle titleStyle = workbook.createCellStyle();
+        titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        Font titleFont = workbook.createFont();
+        titleFont.setFontHeightInPoints((short) 20);
+        titleFont.setBoldweight((short) 700);
+        titleStyle.setFont(titleFont);
+        // 列头样式
+//        CellStyle headerStyle = workbook.createCellStyle();
+//        headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
+//        headerStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+//        headerStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+//        headerStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
+//        headerStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
+//        headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+//        Font headerFont = workbook.createFont();
+//        headerFont.setFontHeightInPoints((short) 12);
+//        headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+//        headerStyle.setFont(headerFont);
+        // 单元格样式
+//        CellStyle cellStyle = workbook.createCellStyle();
+//        cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
+//        cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+//        cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+//        cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
+//        cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
+//        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+//        cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+//        Font cellFont = workbook.createFont();
+//        cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
+//        cellStyle.setFont(cellFont);
+        // 生成一个(带标题)表格
+        SXSSFSheet sheet = workbook.createSheet();
+        //设置列宽
+        int minBytes = colWidth < DEFAULT_COLOUMN_WIDTH ? DEFAULT_COLOUMN_WIDTH : colWidth;//至少字节数
+        int[] arrColWidth = new int[headMap.size()];
+        // 产生表格标题行,以及设置列宽
+        String[] properties = new String[headMap.size()];
+        String[] headers = new String[headMap.size()];
+        int ii = 0;
+        for (Iterator<String> iter = headMap.keySet().iterator(); iter
+                .hasNext(); ) {
+            String fieldName = iter.next();
+
+            properties[ii] = fieldName;
+            headers[ii] = headMap.get(fieldName);
+
+            int bytes = fieldName.getBytes().length;
+            arrColWidth[ii] = bytes < minBytes ? minBytes : bytes;
+            sheet.setColumnWidth(ii, arrColWidth[ii] * 256);
+            ii++;
+        }
+        // 遍历集合数据,产生数据行
+        int rowIndex = 0;
+        for (Object obj : jsonArray) {
+            if (rowIndex == 65535 || rowIndex == 0) {
+                if (rowIndex != 0) {
+                    sheet = workbook.createSheet();//如果数据超过了,则在第二页显示
+                }
+
+//                SXSSFRow titleRow = sheet.createRow(0);//表头 rowIndex=0
+//                titleRow.createCell(0).setCellValue(title);
+//                titleRow.getCell(0).setCellStyle(titleStyle);
+//                sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headMap.size() - 1));
+
+//                SXSSFRow headerRow = sheet.createRow(0); //列头 rowIndex =1
+//                for (int i = 0; i < headers.length; i++) {
+//                    headerRow.createCell(i).setCellValue(headers[i]);
+//                    headerRow.getCell(i).setCellStyle(headerStyle);
+//
+//                }
+                rowIndex = 0;//数据内容从 rowIndex=2开始
+            }
+            JSONObject jo = (JSONObject) JSONObject.toJSON(obj);
+            SXSSFRow dataRow = sheet.createRow(rowIndex);
+            for (int i = 0; i < properties.length; i++) {
+                SXSSFCell newCell = dataRow.createCell(i);
+
+                Object o = jo.get(properties[i]);
+                String cellValue = "";
+                if (o == null) {
+                    cellValue = "";
+                } else if (o instanceof Date) {
+                    cellValue = new SimpleDateFormat(datePattern).format(o);
+                } else if (o instanceof Float || o instanceof Double) {
+                    cellValue = new BigDecimal(o.toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
+                } else {
+                    cellValue = o.toString();
+                }
+
+                newCell.setCellValue(cellValue);
+//                newCell.setCellStyle(cellStyle);
+            }
+            rowIndex++;
+        }
+        // 自动调整宽度
+        /*for (int i = 0; i < headers.length; i++) {
+            sheet.autoSizeColumn(i);
+        }*/
+        try {
+            workbook.write(out);
+            workbook.close();
+            workbook.dispose();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 94 - 0
src/main/java/com/jkcredit/asychronous/util/FtpUtil.java

@@ -0,0 +1,94 @@
+package com.jkcredit.asychronous.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPReply;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+@Slf4j
+public class FtpUtil {
+
+    private FTPClient ftp;
+
+
+    public FtpUtil(String addr, int port, String username, String password) throws IOException {
+        ftp = new FTPClient();
+        ftp.connect(addr, port);
+        ftp.login(username, password);
+        ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
+        int reply;
+        reply = ftp.getReplyCode();
+        if (!FTPReply.isPositiveCompletion(reply)) {
+            ftp.disconnect();
+        }
+    }
+
+    /**
+     * @param path 上传到ftp服务器哪个路径下
+     * @return
+     * @throws Exception
+     */
+    public void connect(String path) throws Exception {
+        ftp.changeWorkingDirectory(path);
+    }
+
+    public boolean makeDirectory(String path) throws IOException {
+        return ftp.makeDirectory(path);
+    }
+
+
+    /**
+     * @param file 上传的文件或文件夹
+     * @throws Exception
+     */
+    public void upload(File file) throws Exception {
+        if (file.isDirectory()) {
+            ftp.makeDirectory(file.getName());
+            ftp.changeWorkingDirectory(file.getName());
+            String[] files = file.list();
+            for (int i = 0; i < files.length; i++) {
+                File file1 = new File(file.getPath() + File.separator + files[i]);
+                if (file1.isDirectory()) {
+                    upload(file1);
+                    ftp.changeToParentDirectory();
+                } else {
+                    File file2 = new File(file.getPath() + File.separator + files[i]);
+                    FileInputStream input = new FileInputStream(file2);
+                    ftp.storeFile(file.getName(), input);
+                    input.close();
+                }
+            }
+            log.info("文件上传");
+        } else {
+            File file2 = new File(file.getPath());
+            FileInputStream input = new FileInputStream(file2);
+            ftp.enterLocalPassiveMode();
+            boolean result = ftp.storeFile(file.getName(), input);
+            input.close();
+            log.info("文件上传:{}", result);
+        }
+    }
+
+    public static void fileUpload(String host, Integer port, String userName, String passWord, String dir, String fileName) {
+        try {
+//            log.info("文件开始上传");
+            FtpUtil ftp = new FtpUtil(host, port, userName, passWord);
+            ftp.connect(dir);
+            File file = new File(fileName);
+            ftp.upload(file);
+            ftp.destroy();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void destroy() throws IOException {
+        if (ftp != null) {
+            ftp.disconnect();
+            ftp = null;
+        }
+    }
+}

+ 56 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,56 @@
+spring:
+  data:
+    mongodb:
+      uri: mongodb://172.31.1.10:27017/asychronous
+  application:
+    name: asychronous
+  rabbitmq:
+    host: 122.14.207.194
+    port: 5672
+    username: szn
+    password: szn
+    publisher-confirms: true
+    publisher-returns: true
+    listener:
+      direct:
+        acknowledge-mode: manual
+      simple:
+        acknowledge-mode: manual
+#java进程在后台运行
+camel:
+  springboot:
+    main-run-controller: true
+manftp:
+  download:
+    ftp: ftp://jkxy@git.jkcredit.com:30021/download/man/?password=jkxy1234&delay=5s&delete=true&readLock=fileLock&disconnect=true&recursive=true&streamDownload=true&passiveMode=true
+    dir: file:/Users/sunzhaoning/ftp/down/man
+    info: /Users/sunzhaoning/ftp/down/man
+  upload:
+    local: /Users/sunzhaoning/ftp/upload/man
+carftp:
+  download:
+    ftp: ftp://jkxy@git.jkcredit.com:30021/download/car/?password=jkxy1234&delay=5s&delete=true&readLock=fileLock&disconnect=true&recursive=true&streamDownload=true&passiveMode=true
+    dir: file:/Users/sunzhaoning/ftp/down/car
+    info: /Users/sunzhaoning/ftp/down/car
+  upload:
+     local: /Users/sunzhaoning/ftp/upload/car
+
+# 上传文件配置
+ftp:
+  host: git.jkcredit.com
+  port: 30021
+  username: jkxy
+  password: jkxy1234
+  dir:
+    man: upload/man
+    car: upload/car
+server:
+  port: 10081
+
+#logging:
+#  level:
+#    org:
+#      springframework:
+#        data:
+#          mongodb:
+#            core: DEBUG

+ 56 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,56 @@
+spring:
+  data:
+    mongodb:
+      uri: mongodb://xadmin:xadminxadmin@192.168.1.99:27017,192.168.1.99:27018,192.168.1.99:27019/asychronous
+  application:
+    name: asychronous
+  rabbitmq:
+    host: 192.168.1.91
+    port: 5672
+    username: szn
+    password: szn
+    publisher-confirms: true
+    publisher-returns: true
+    listener:
+      direct:
+        acknowledge-mode: manual
+      simple:
+        acknowledge-mode: manual
+#java进程在后台运行
+camel:
+  springboot:
+    main-run-controller: true
+manftp:
+  download:
+    ftp: ftp://jkxyftp@192.168.1.99:21/download/man/?password=jkxyftp&delay=5s&delete=true&readLock=fileLock&passiveMode=true
+    dir: file:/data/ftp/down/man
+    info: /data/ftp/down/man
+  upload:
+    local: /data/ftp/upload/man
+carftp:
+  download:
+    ftp: ftp://jkxyftp@192.168.1.99:21/download/car/?password=jkxyftp&delay=5s&delete=true&readLock=fileLock&passiveMode=true
+    dir: file:/data/ftp/down/car
+    info: /data/ftp/down/car
+  upload:
+    local: /data/ftp/upload/car
+
+# 上传文件配置
+ftp:
+  host: 192.168.1.99
+  port: 21
+  username: jkxyftp
+  password: jkxyftp
+  dir:
+    man: upload/man
+    car: upload/car
+server:
+  port: 10081
+
+#logging:
+#  level:
+#    org:
+#      springframework:
+#        data:
+#          mongodb:
+#            core: DEBUG

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

@@ -0,0 +1,3 @@
+spring:
+  profiles:
+    active: prod

+ 121 - 0
src/main/resources/logback-spring.xml

@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
+<!-- 日志输出规则  根据当前ROOT 级别,日志输出时,级别高于root默认的级别时  会输出 -->
+<!-- 以下  每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志-->
+
+
+<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
+    debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- 定义日志文件 输入位置 -->
+    <property name="log_dir" value="logs/as" />
+    <!-- 日志最大的历史 30天 -->
+    <property name="maxHistory" value="30"/>
+
+
+
+
+    <!-- ConsoleAppender 控制台输出日志 -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <!-- 对日志进行格式化 -->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
+        </encoder>
+    </appender>
+
+
+    <!-- ERROR级别日志 -->
+    <!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender-->
+    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 过滤器,只记录WARN级别的日志 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志输出位置  可相对、和绝对路径 -->
+            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/error.log</fileNamePattern>
+            <!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6,
+            则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除-->
+            <maxHistory>${maxHistory}</maxHistory>
+        </rollingPolicy>
+
+        <!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+          <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern>
+          <minIndex>1</minIndex>
+          <maxIndex>3</maxIndex>
+        </rollingPolicy>   -->
+        <!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+            <maxFileSize>5MB</maxFileSize>
+        </triggeringPolicy>   -->
+
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <!-- INFO级别日志 appender -->
+    <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 过滤器,只记录INFO级别的日志 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 按天回滚 daily -->
+            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info.log
+            </fileNamePattern>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>${maxHistory}</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss} %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <!-- DEBUG级别日志 appender -->
+    <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 过滤器,只记录DEBUG级别的日志 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>DEBUG</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 按天回滚 daily -->
+            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/debug.log
+            </fileNamePattern>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>${maxHistory}</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="java.sql.PreparedStatement" value="DEBUG" />
+    <logger name="java.sql.Connection" value="DEBUG" />
+    <logger name="java.sql.Statement" value="DEBUG" />
+    <logger name="com.ibatis" value="DEBUG" />
+    <logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG" />
+    <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG"/>
+    <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" value="DEBUG" />
+
+    <!-- root级别   DEBUG -->
+    <root level="INFO">
+        <!-- 控制台输出 -->
+        <appender-ref ref="STDOUT" />
+        <!-- 文件输出 -->
+        <appender-ref ref="ERROR" />
+        <appender-ref ref="INFO" />
+        <!--<appender-ref ref="WARN" />-->
+        <!--<appender-ref ref="DEBUG" />-->
+        <!--<appender-ref ref="TRACE" />-->
+    </root>
+</configuration>

+ 16 - 0
src/test/java/com/jkcredit/asychronous/AsychronousApplicationTests.java

@@ -0,0 +1,16 @@
+package com.jkcredit.asychronous;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AsychronousApplicationTests {
+
+    @Test
+    public void contextLoads() {
+    }
+
+}