wuhongshuang há 2 anos atrás
pai
commit
2c10e662f5
35 ficheiros alterados com 3039 adições e 0 exclusões
  1. 37 0
      .gitignore
  2. 41 0
      README.md
  3. 19 0
      src/main/java/com/szwl/Application.java
  4. 41 0
      src/main/java/com/szwl/config/AsyncExecutorConfig.java
  5. 23 0
      src/main/java/com/szwl/config/MybatisPlusConfig.java
  6. 44 0
      src/main/java/com/szwl/config/SwaggerConfig.java
  7. 9 0
      src/main/java/com/szwl/constant/CacheConsts.java
  8. 14 0
      src/main/java/com/szwl/constant/ConfigConsts.java
  9. 77 0
      src/main/java/com/szwl/constant/ResponseCodesEnum.java
  10. 83 0
      src/main/java/com/szwl/controller/DemoController.java
  11. 35 0
      src/main/java/com/szwl/exception/AuthenticationException.java
  12. 35 0
      src/main/java/com/szwl/exception/BizException.java
  13. 13 0
      src/main/java/com/szwl/exception/MyException.java
  14. 27 0
      src/main/java/com/szwl/exception/ParamNotFoundException.java
  15. 95 0
      src/main/java/com/szwl/exception/RestExceptionHandler.java
  16. 21 0
      src/main/java/com/szwl/feign/config/FeignConfig.java
  17. 45 0
      src/main/java/com/szwl/feign/interceptor/FeignClientRequestHeaderInterceptor.java
  18. 43 0
      src/main/java/com/szwl/mapper/xml/TAdminMapper.xml
  19. 18 0
      src/main/java/com/szwl/model/bo/BasePageQuery.java
  20. 52 0
      src/main/java/com/szwl/model/bo/R.java
  21. 78 0
      src/main/java/com/szwl/model/bo/ResponseModel.java
  22. 119 0
      src/main/java/com/szwl/model/entity/TAdmin.java
  23. 27 0
      src/main/java/com/szwl/model/query/TAdminParam.java
  24. 57 0
      src/main/java/com/szwl/model/utils/AdminUtils.java
  25. 117 0
      src/main/java/com/szwl/model/utils/Base64Util.java
  26. 17 0
      src/main/java/com/szwl/model/utils/CodeUtil.java
  27. 74 0
      src/main/java/com/szwl/model/utils/Constant.java
  28. 266 0
      src/main/java/com/szwl/model/utils/DateUtils.java
  29. 396 0
      src/main/java/com/szwl/model/utils/Filter.java
  30. 332 0
      src/main/java/com/szwl/model/utils/HttpClientUtils.java
  31. 270 0
      src/main/java/com/szwl/model/utils/JoinpayConstant.java
  32. 136 0
      src/main/java/com/szwl/model/utils/JsonUtils.java
  33. 293 0
      src/main/java/com/szwl/model/utils/PushUtils.java
  34. 11 0
      src/test/java/com/szwl/ApplicationTests.java
  35. 74 0
      src/test/java/com/szwl/AutoGeneratorTests.java

+ 37 - 0
.gitignore

@@ -0,0 +1,37 @@
+# Created by .ignore support plugin (hsz.mobi)
+
+# Operating System Files
+
+*.DS_Store
+Thumbs.db
+*.sw?
+.#*
+*#
+*~
+*.sublime-*
+
+# Build Artifacts
+
+.gradle/
+build/
+target/
+bin/
+dependency-reduced-pom.xml
+.factorypath
+
+# Eclipse Project Files
+
+.classpath
+.project
+.settings/
+workspace.xml
+
+# IntelliJ IDEA Files
+
+*.iml
+*.ipr
+*.iws
+*.idea
+
+# other code repositories
+.svn

+ 41 - 0
README.md

@@ -0,0 +1,41 @@
+# szwlServer 申泽移动物联
+
+## 注册中心
+http://112.74.63.148:49001/
+可以看到各子服务
+
+## 自动生成代码
+运行 AutoGeneratorTests
+
+## mybatis-plus
+增删查改
+使用参考 https://baomidou.com/pages/24112f/
+
+## swwager2 生成接口文档
+在controller 加上@Api(value = "/test", tags = {"controller描述"})
+接口方法上加上 @ApiOperation(value = "接口描述") 即可。
+文档地址:http://127.0.0.1:端口/doc.html
+
+## 接口返回
+参考 DemoController
+返回体,用 成功:R.ok()  ,默认返回码 00000
+失败:R.fail(ResponseCodesEnum.B0001,"你的错误信息");
+ResponseCodesEnum 为错误码,其中 ALL_OK("00000","SUCCESS") 表示成功
+
+## 子服务之间使用feign 互相调用
+参考 PayFeign
+
+## 使用 hutool 工具类
+参考文档 https://www.bookstack.cn/read/hutool/377f64112be7197a.md
+
+## 配置文件参数使用
+推荐将配置文件的参数,放到数据库表 sys_properties 里面。
+参考 select * from sys_properties a where a.application ='szwl-server'
+使用 参考 DemoController 的 @Value("${test.value:bbb}")
+
+## 部署说明
+把jar 包 放到 /app/appsystem/springcloud
+启动命令:/app/appsystem/startSpringCloud.sh  /app/appsystem/springcloud/你的包名.jar
+查看状态:/app/appsystem/checkSpringCloud.sh
+关闭命令:/app/appsystem/stopSpringCloud.sh /app/appsystem/springcloud/你的包名.jar
+查看日志:vi /app/applogs/szwl-server/szwl-server.log

+ 19 - 0
src/main/java/com/szwl/Application.java

@@ -0,0 +1,19 @@
+package com.szwl;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@EnableEurekaClient
+@EnableFeignClients
+@MapperScan("com.szwl.mapper")
+@SpringBootApplication(scanBasePackages = {"com.szwl", "cn.com.crbank.ommo.exception","cn.com.crbank.ommo.esclient"})
+public class Application{
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+}
+
+

+ 41 - 0
src/main/java/com/szwl/config/AsyncExecutorConfig.java

@@ -0,0 +1,41 @@
+package com.szwl.config;
+
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+/**
+ * 异步注解线程池配置
+ *
+ * @author wuhs
+ * @date 2021-10-08 16:36
+ */
+@Configuration
+@ConditionalOnProperty(name = "ommo.common.async.executor.override", havingValue = "true")
+public class AsyncExecutorConfig implements AsyncConfigurer {
+
+    private static final int CORE_NUMS = Runtime.getRuntime().availableProcessors();
+
+    @Override
+    public Executor getAsyncExecutor() {
+        ThreadPoolTaskExecutor asyncExecutor = new ThreadPoolTaskExecutor();
+        //根据io密集型创建线程池
+        asyncExecutor.setCorePoolSize(2 * CORE_NUMS);
+        asyncExecutor.setMaxPoolSize(5 * CORE_NUMS);
+        asyncExecutor.setKeepAliveSeconds(60);
+        asyncExecutor.setQueueCapacity(100);
+        asyncExecutor.setThreadNamePrefix("async-executor-");
+        asyncExecutor.initialize();
+        return asyncExecutor;
+    }
+
+    @Override
+    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+        return new SimpleAsyncUncaughtExceptionHandler();
+    }
+}

+ 23 - 0
src/main/java/com/szwl/config/MybatisPlusConfig.java

@@ -0,0 +1,23 @@
+package com.szwl.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@EnableTransactionManagement
+public class MybatisPlusConfig {
+    /**
+     * 分页插件,自动识别数据库类型 多租户,请参考官网【插件扩展】
+     */
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+
+}

+ 44 - 0
src/main/java/com/szwl/config/SwaggerConfig.java

@@ -0,0 +1,44 @@
+package com.szwl.config;
+
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+@EnableKnife4j
+public class SwaggerConfig {
+    @Value("${spring.application.name:}")
+    String applicationName;
+
+    private static final String SPLIT = ";";
+
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo()).select()
+                .apis(RequestHandlerSelectors.basePackage("com.szwl"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+    /**
+     * http://127.0.0.1:端口/doc.html
+     * @return
+     */
+    private ApiInfo apiInfo() {
+        String title = applicationName + "后台接口";
+        return new ApiInfoBuilder().title(title)
+                .description(title)
+//				.termsOfServiceUrl("www.xxx.com").license("http://www.apache.org/licenses/LICENSE-2.0")
+                .version("1.0")
+                .build();
+    }
+}

+ 9 - 0
src/main/java/com/szwl/constant/CacheConsts.java

@@ -0,0 +1,9 @@
+package com.szwl.constant;
+
+/**
+ * 缓存相关常量
+ */
+public class CacheConsts {
+    public static final String USER_ALL_LIST = "test";
+
+}

+ 14 - 0
src/main/java/com/szwl/constant/ConfigConsts.java

@@ -0,0 +1,14 @@
+package com.szwl.constant;
+
+/**
+ * 系统配置相关常量
+ */
+public class ConfigConsts {
+    public static final String TEST = "TEST";
+    /**
+     * token
+     * 请求头:Authorization
+     */
+    public static final String AUTHORIZATION = "Authorization";
+    public static final String INNER_FEIGN = "innerFeign";
+}

+ 77 - 0
src/main/java/com/szwl/constant/ResponseCodesEnum.java

@@ -0,0 +1,77 @@
+package com.szwl.constant;
+
+public enum ResponseCodesEnum {
+    ALL_OK("00000","SUCCESS"),
+    A0001("A0001","用户端参数错误"),
+    A0002("A0002","用户端错误"),
+    A0100("A0100","用户注册错误"),
+    A0101("A0101", "出生日期格式错误"),
+    A0200("A0200", "用户编号已存在"),
+    A0201("A0201", "用户登录名已存在"),
+    A0202("A0202", "用户手机号已存在"),
+    A0203("A0203", "用户组已存在"),
+    A0204("A0204", "用户ID集合不能为空"),
+    A0205("A0205", "用户名不能为空"),
+    A0206("A0206", "用户不存在"),
+    A0207("A0207", "用户邮箱已存在"),
+    A0300("A0300", "机构号已存在"),
+    A0301("A0301", "机构不存在"),
+    A0302("A0302", "找不到机构对应的上级机构"),
+    A0500("A0500", "角色名称已存在"),
+    A0600("A0600", "值班信息已存在"),
+    A0601("A0601", "已有值班签到记录,请勿重复签到"),
+    A0700("A0700", "通知任务不存在"),
+    A0800("A0800", "外围接口KEY已存在"),
+    A0900("A0900", "用户已绑定其他设备"),
+    A0901("A0901", "用户已绑定该设备"),
+    A0902("A0902", "用户未绑定任何设备"),
+    B0001("B0001","系统执行出错"),
+    B0002("B0002","系统插入数据出错"),
+    B0003("B0003","系统更新数据出错"),
+    B0004("B0004","系统删除数据出错"),
+    B0005("B0005","系统获取数据出错"),
+    C0001("C0001","调用第三方服务出错"),
+    C0110("C0110","RPC服务出错"),
+    C0111("C0111","RPC服务未找到"),
+    C0130("C0130","缓存服务出错"),
+    E0001("E0001","SSH连接参数错误"),
+    E0002("E0002","SSH连接失败"),
+    E0003("E0003","SSH连接执行命令失败"),
+    E0004("E0004","SSH参数错误"),
+    E0101("E0101","ZABBIX认证失败"),
+    E0102("E0102","ZABBIX参数错误"),
+    E0103("E0103","ZABBIX返回错误"),
+    E0104("E0104","SNMP参数错误"),
+    E0105("E0105","SNMP解析错误"),
+    L0001("L0001","用户未登陆"),
+    L0002("L0002","用户名或密码错误,请重新输入"),
+    L0003("L0003","用户被禁用"),
+    L0004("L0004","SECURITY内部错误"),
+    L0005("L0005","安全认证不通过"),//统一的SecurityFilter过滤器,校验请求不同过返回码
+    L0006("L0006","TOKEN不可用,请重新登录"),
+    F0000("F0000","文件上传错误"),
+    F0001("F0001","文件ID不存在"),
+    F0002("F0002","找不到文件"),
+    F0003("F0003","文件下载错误"),
+    F0004("F0004","图片预览错误"),
+    F0005("F0005","读取文件失败"),
+    S0001("S0001","定时任务不存在"),
+    P0001("P0001","无权限访问"),
+    P0002("P0002","无权限删除");
+
+
+    private final String errorCode;
+    private final String errorMessage;
+
+    private ResponseCodesEnum(String errorCode, String errorMessage) {
+        this.errorCode = errorCode;
+        this.errorMessage = errorMessage;
+    }
+    public String code() {
+        return errorCode;
+    }
+    public String message() {
+        return errorMessage;
+    }
+
+}

+ 83 - 0
src/main/java/com/szwl/controller/DemoController.java

@@ -0,0 +1,83 @@
+package com.szwl.controller;
+
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.szwl.constant.ResponseCodesEnum;
+import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TAdmin;
+import com.szwl.model.query.TAdminParam;
+import com.szwl.service.TAdminService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+@Api(value = "/test", tags = {"测试接口"})
+@RestController
+@RequestMapping("/test")
+public class DemoController {
+    @Value("${test.value:bbb}")
+    private String testValue;
+    @Autowired
+    TAdminService tAdminService;
+
+    @ApiOperation(value = "测试更新")
+    @PostMapping("/update")
+    public ResponseModel<?> testUpdate(TAdmin entity) {
+        return R.ok(tAdminService.saveOrUpdate(entity));
+    }
+
+
+    @GetMapping("/testPay")
+    public ResponseModel<?> testPay(String id) {
+        return R.ok(tAdminService.getById(id));
+    }
+    @ApiOperation(value = "分页查询")
+    @GetMapping("/testPage")
+    public ResponseModel<IPage<?>> testPage(TAdminParam param) {
+        LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
+        query.eq(TAdmin::getIsEnabled,true);
+        if(StrUtil.isNotBlank(param.getName())){
+            query.like(TAdmin::getName,param.getName());
+        }
+        query.orderByDesc(TAdmin::getApplyStartTime);
+        Page<TAdmin> page = new Page<>(param.getCurrent(), param.getSize(), true);
+        IPage<TAdmin> iPage = tAdminService.page(page, query);
+        return R.ok(iPage);
+    }
+
+    @ApiOperation(value = "列表查询")
+    @GetMapping("/testList")
+    public ResponseModel<List<?>> testList(TAdminParam param) {
+        LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
+        query.eq(TAdmin::getIsEnabled,true);
+        if(StrUtil.isNotBlank(param.getName())){
+            query.like(TAdmin::getName,param.getName());
+        }
+        query.orderByDesc(TAdmin::getApplyStartTime);
+        List<TAdmin> list = tAdminService.list(query);
+        return R.ok(list);
+    }
+    @ApiOperation(value = "返回失败")
+    @GetMapping("/testError")
+    public ResponseModel<List<?>> testError(boolean success) {
+        if(success){
+            return R.ok();
+        }else{
+            return R.fail(ResponseCodesEnum.B0001,"你的错误信息");
+        }
+    }
+}
+

+ 35 - 0
src/main/java/com/szwl/exception/AuthenticationException.java

@@ -0,0 +1,35 @@
+package com.szwl.exception;
+
+import com.szwl.constant.ResponseCodesEnum;
+import lombok.Data;
+import org.springframework.util.Assert;
+
+/**
+ * 认证异常,使用统一异常处理
+ *
+ * @author wuhs
+ * @date 2021-09-29 11:03
+ */
+@Data
+public class AuthenticationException extends RuntimeException {
+
+    private String code;
+
+    private String message;
+
+    private ResponseCodesEnum responseCodesEnum;
+
+    public AuthenticationException(ResponseCodesEnum responseCodesEnum) {
+        Assert.notNull(responseCodesEnum, "enum must not be null");
+        this.code = responseCodesEnum.code();
+        this.message = responseCodesEnum.message();
+        this.responseCodesEnum = responseCodesEnum;
+    }
+
+    public AuthenticationException(ResponseCodesEnum responseCodesEnum, String msg) {
+        Assert.notNull(responseCodesEnum, "enum must not be null");
+        this.code = responseCodesEnum.code();
+        this.message = responseCodesEnum.message() +","+ msg;
+        this.responseCodesEnum = responseCodesEnum;
+    }
+}

+ 35 - 0
src/main/java/com/szwl/exception/BizException.java

@@ -0,0 +1,35 @@
+package com.szwl.exception;
+
+import com.szwl.constant.ResponseCodesEnum;
+import lombok.Data;
+import org.springframework.util.Assert;
+
+/**
+ * 业务异常,使用统一异常处理
+ *
+ * @author wuhs
+ * @date 2021-09-29 11:03
+ */
+@Data
+public class BizException extends RuntimeException {
+
+    private String code;
+
+    private String message;
+
+    private ResponseCodesEnum responseCodesEnum;
+
+    public BizException(ResponseCodesEnum responseCodesEnum) {
+        Assert.notNull(responseCodesEnum, "enum must not be null");
+        this.code = responseCodesEnum.code();
+        this.message = responseCodesEnum.message();
+        this.responseCodesEnum = responseCodesEnum;
+    }
+
+    public BizException(ResponseCodesEnum responseCodesEnum,String msg) {
+        Assert.notNull(responseCodesEnum, "enum must not be null");
+        this.code = responseCodesEnum.code();
+        this.message = responseCodesEnum.message() +","+ msg;
+        this.responseCodesEnum = responseCodesEnum;
+    }
+}

+ 13 - 0
src/main/java/com/szwl/exception/MyException.java

@@ -0,0 +1,13 @@
+package com.szwl.exception;
+
+import lombok.Data;
+
+@Data
+public class MyException extends RuntimeException {
+    private static final long serialVersionUID = -2565431806475335331L;
+    String message;
+
+    public MyException(String message) {
+        this.message = message;
+    }
+}

+ 27 - 0
src/main/java/com/szwl/exception/ParamNotFoundException.java

@@ -0,0 +1,27 @@
+package com.szwl.exception;
+
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+/**
+ * 参数不符或缺失时报错
+ *
+ * @author 吴洪双
+ */
+@Accessors(chain = true)
+@Setter
+public class ParamNotFoundException extends RuntimeException {
+
+    private static final long serialVersionUID = -2565431806475335331L;
+    private String paramName;
+
+    public ParamNotFoundException(String paramName) {
+        this.paramName = paramName;
+    }
+
+    @Override
+    public String getMessage() {
+        return paramName + " 不能为空";
+    }
+
+}

+ 95 - 0
src/main/java/com/szwl/exception/RestExceptionHandler.java

@@ -0,0 +1,95 @@
+package com.szwl.exception;
+
+import com.alibaba.fastjson.JSON;
+import com.szwl.constant.ResponseCodesEnum;
+import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.BindException;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Slf4j
+@RestControllerAdvice
+public class RestExceptionHandler {
+
+    @ExceptionHandler(Exception.class)
+    public ResponseModel<Void> otherExceptionHandler(Exception exception) {
+        log.error("un caught exception: ", exception);
+        return R.fail("内部异常[%s],请联系管理员。", exception.getMessage());
+    }
+
+    @ExceptionHandler(MyException.class)
+    public ResponseModel<Void> myExceptionHandler(Exception exception) {
+        log.error("my exception: ", exception);
+        return R.fail("业务异常[%s],请联系管理员。", exception.getMessage());
+    }
+
+    @ExceptionHandler(ParamNotFoundException.class)
+    public ResponseModel<Void> paramNotFoundExceptionHandler(Exception exception) {
+        log.error("param not found exception: ", exception);
+        return R.fail(ResponseCodesEnum.A0001,"参数异常[%s],请联系管理员。", exception.getMessage());
+    }
+
+    /**
+     * 处理业务异常
+     *
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(BizException.class)
+    public ResponseModel<Void> handlerBizException(BizException e) {
+        log.error("biz exception: {}", e.getMessage());
+        return R.fail(e.getResponseCodesEnum(), "业务异常[%s],请联系管理员。", e.getMessage());
+    }
+
+    /**
+     * 校验错误拦截处理
+     *
+     * @param ex 错误信息集合
+     * @return 错误信息
+     * @Title: methodArgumentNotValidHandler
+     */
+    @ExceptionHandler({MethodArgumentNotValidException.class, BindException.class})
+    public ResponseModel<Void> methodArgumentNotValidHandler(HttpServletRequest request, Exception ex) {
+        BindingResult result = null;
+        if (ex instanceof BindException) {
+            BindException bindException = (BindException) ex;
+            result = bindException.getBindingResult();
+        } else if (ex instanceof MethodArgumentNotValidException) {
+            MethodArgumentNotValidException methodArgumentNotValidException = (MethodArgumentNotValidException) ex;
+            result = methodArgumentNotValidException.getBindingResult();
+        }
+        StringBuilder msg = new StringBuilder();
+        if (result != null) {
+            if (result.getFieldErrorCount() > 0) {
+                for (FieldError fieldErr : result.getFieldErrors()) {
+                    msg.append(fieldErr.getField() + ":" + fieldErr.getDefaultMessage()).append("|");
+                }
+            }
+            log.error("error by url:{}", request.getRequestURI().toString());
+            log.error("request param:{}", JSON.toJSONString(result.getTarget()));
+            log.error("response msg:{}", msg.toString());
+        }
+        return R.fail(ResponseCodesEnum.A0001, "接口参数错误:%s", msg);
+    }
+
+    /**
+     * 认证异常
+     *
+     * @param exception
+     * @return
+     */
+    @ExceptionHandler(AuthenticationException.class)
+    public ResponseModel<Void> authenticationExceptionHandler(AuthenticationException exception) {
+        log.error("common authentication exception: ", exception);
+        return R.fail(exception.getResponseCodesEnum(), exception.getMessage());
+    }
+
+
+}

+ 21 - 0
src/main/java/com/szwl/feign/config/FeignConfig.java

@@ -0,0 +1,21 @@
+package com.szwl.feign.config;
+
+import com.szwl.feign.interceptor.FeignClientRequestHeaderInterceptor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author PT-ZHOUYUHENG
+ * @date 2021-11-04 10:38
+ */
+@Configuration
+@Slf4j
+public class FeignConfig {
+    @Bean
+    public FeignClientRequestHeaderInterceptor feignClientRequestHeaderInterceptor() {
+        log.info("--feign client request header interceptor reg");
+        return new FeignClientRequestHeaderInterceptor();
+    }
+
+}

+ 45 - 0
src/main/java/com/szwl/feign/interceptor/FeignClientRequestHeaderInterceptor.java

@@ -0,0 +1,45 @@
+package com.szwl.feign.interceptor;
+
+import com.szwl.constant.ConfigConsts;
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Enumeration;
+
+
+/**
+ * feign请求带上前端的token
+ * @author wuhs
+ */
+@Slf4j
+public class FeignClientRequestHeaderInterceptor implements RequestInterceptor {
+    @Value("${spring.application.name:}")
+    private String applicationName;
+
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        //获取请求对象
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (null != attributes) {
+            HttpServletRequest request = attributes.getRequest();
+            //找出当前请求头
+            Enumeration<String> headers = request.getHeaderNames();
+            //把所有请求头加入
+            while (headers.hasMoreElements()) {
+                String name = headers.nextElement();
+                if ("content-length".equalsIgnoreCase(name)) {
+                    continue;
+                }
+                String value = request.getHeader(name);
+                requestTemplate.header(name, value);
+            }
+        }
+        //添加内部跳过鉴权请求头
+        requestTemplate.header(ConfigConsts.INNER_FEIGN, "1");
+    }
+}

+ 43 - 0
src/main/java/com/szwl/mapper/xml/TAdminMapper.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.szwl.mapper.TAdminMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.szwl.model.entity.TAdmin">
+        <id column="id" property="id" />
+        <result column="create_date" property="createDate" />
+        <result column="modify_date" property="modifyDate" />
+        <result column="area_id" property="areaId" />
+        <result column="email" property="email" />
+        <result column="is_admined" property="isAdmined" />
+        <result column="is_enabled" property="isEnabled" />
+        <result column="is_locked" property="isLocked" />
+        <result column="locked_date" property="lockedDate" />
+        <result column="login_date" property="loginDate" />
+        <result column="login_failure_count" property="loginFailureCount" />
+        <result column="login_ip" property="loginIp" />
+        <result column="trade_merchant_no" property="tradeMerchantNo" />
+        <result column="name" property="name" />
+        <result column="parent_id" property="parentId" />
+        <result column="password" property="password" />
+        <result column="notice_id" property="noticeId" />
+        <result column="type" property="type" />
+        <result column="username" property="username" />
+        <result column="phone" property="phone" />
+        <result column="is_refund" property="isRefund" />
+        <result column="if_foreign" property="ifForeign" />
+        <result column="open" property="open" />
+        <result column="promo_code_open" property="promoCodeOpen" />
+        <result column="apply_start_time" property="applyStartTime" />
+        <result column="apply_end_time" property="applyEndTime" />
+        <result column="code" property="code" />
+        <result column="pay_platform" property="payPlatform" />
+        <result column="relation_admin_id" property="relationAdminId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, create_date, modify_date, area_id, email, is_admined, is_enabled, is_locked, locked_date, login_date, login_failure_count, login_ip, trade_merchant_no, name, parent_id, password, notice_id, type, username, phone, is_refund, if_foreign, open, promo_code_open, apply_start_time, apply_end_time, code, pay_platform, relation_admin_id
+    </sql>
+
+</mapper>

+ 18 - 0
src/main/java/com/szwl/model/bo/BasePageQuery.java

@@ -0,0 +1,18 @@
+package com.szwl.model.bo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class BasePageQuery {
+    /**
+     * 当前页,默认第一页
+     */
+    @ApiModelProperty(value = "当前页,默认第一页,1")
+    long current = 1L;
+    /**
+     * 每页多少条数据,默认10条
+     */
+    @ApiModelProperty(value = "每页多少条数据,默认10条")
+    long size = 10L;
+}

+ 52 - 0
src/main/java/com/szwl/model/bo/R.java

@@ -0,0 +1,52 @@
+package com.szwl.model.bo;
+
+
+import com.szwl.constant.ResponseCodesEnum;
+import com.szwl.exception.MyException;
+
+public class R<T> {
+
+    public static <T> ResponseModel<T> ok(T data) {
+        return ResponseModel.ok(data);
+    }
+
+    public static <T> ResponseModel<T> ok(T data, String message) {
+        return ResponseModel.ok(data, message);
+    }
+
+    public static <T> ResponseModel<T> ok() {
+        return ResponseModel.ok();
+    }
+    public static <T> ResponseModel<T> okByMsg(String message) {
+        return ResponseModel.okByMsg(message);
+    }
+    public static <T> ResponseModel<T> fail(ResponseCodesEnum code, String message) {
+        return ResponseModel.fail(code,message);
+    }
+
+    public static <T> ResponseModel<T> fail(ResponseCodesEnum code) {
+        return ResponseModel.fail(code);
+    }
+
+    public static <T> ResponseModel<T> fail(String formatter, Object... obj) {
+        return ResponseModel.fail(String.format(formatter, obj));
+    }
+
+    public static <T> ResponseModel<T> fail(ResponseCodesEnum code, String formatter, Object... obj) {
+        return ResponseModel.fail(code, String.format(formatter, obj));
+    }
+
+    /**
+     * 获取feign结果,如果成功获取data,失败抛出异常
+     *
+     * @param resp
+     * @param <T>
+     * @return
+     */
+    public static <T> T getDataIfSuccess(ResponseModel<T> resp) {
+        if (!resp.isSuccess()) {
+            throw new MyException(resp.getMessage());
+        }
+        return resp.getData();
+    }
+}

+ 78 - 0
src/main/java/com/szwl/model/bo/ResponseModel.java

@@ -0,0 +1,78 @@
+package com.szwl.model.bo;
+
+import com.szwl.constant.ResponseCodesEnum;
+import com.fasterxml.jackson.annotation.JsonView;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class ResponseModel<T> extends R<T> {
+
+	public interface NormalView {}
+	public interface FullView extends NormalView {}
+
+	@ApiModelProperty(value = "返回码")
+	@JsonView({NormalView.class})
+	private String code;
+
+	@ApiModelProperty(value = "返回信息")
+	@JsonView({NormalView.class})
+	private String message = "";
+
+	@ApiModelProperty(value = "返回数据")
+	@JsonView({NormalView.class})
+	private T data;
+
+	public static <T> ResponseModel<T> ok(T data) {
+		return new ResponseModel<T>()
+				.setCode(ResponseCodesEnum.ALL_OK.code())
+				.setData(data);
+	}
+	
+	public static <T> ResponseModel<T> ok(T data, String message) {
+		return new ResponseModel<T>()
+				.setCode(ResponseCodesEnum.ALL_OK.code())
+				.setMessage(message)
+				.setData(data);
+	}
+	
+	public static <T> ResponseModel<T> ok() {
+		return new ResponseModel<T>()
+				.setCode(ResponseCodesEnum.ALL_OK.code());
+	}
+	public static <T> ResponseModel<T> okByMsg(String message) {
+		return new ResponseModel<T>()
+				.setCode(ResponseCodesEnum.ALL_OK.code())
+				.setMessage(message);
+	}
+	public static <T> ResponseModel<T> fail(ResponseCodesEnum code,String message) {
+		return new ResponseModel<T>()
+				.setCode(code.code())
+				.setMessage(message);
+	}
+
+	public static <T> ResponseModel<T> fail(ResponseCodesEnum code) {
+		return new ResponseModel<T>()
+				.setCode(code.code())
+				.setMessage(code.message());
+	}
+
+	public static <T> ResponseModel<T> fail(String message) {
+		return new ResponseModel<T>()
+				.setCode(ResponseCodesEnum.B0001.code())
+				.setMessage(message);
+	}
+
+	/**
+	 * 校验是否成功
+	 *
+	 * @return
+	 */
+	public boolean isSuccess() {
+		return ResponseCodesEnum.ALL_OK.code().equalsIgnoreCase(this.getCode());
+	}
+}

+ 119 - 0
src/main/java/com/szwl/model/entity/TAdmin.java

@@ -0,0 +1,119 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.szwl.model.utils.AdminUtils;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.beans.Transient;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-03-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TAdmin对象", description="")
+public class TAdmin implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    private Long areaId;
+
+    @ApiModelProperty(value = "邮箱;")
+    private String email;
+
+    @ApiModelProperty(value = "设置是否普通管理员(0:管理员,1:子账户);")
+    private Boolean isAdmined;
+
+    @ApiModelProperty(value = "是否启用;")
+    private Boolean isEnabled;
+
+    @ApiModelProperty(value = "是否锁定;")
+    private Boolean isLocked;
+
+    @ApiModelProperty(value = "锁定时间;")
+    private Date lockedDate;
+
+    @ApiModelProperty(value = "登录时间;")
+    private Date loginDate;
+
+    @ApiModelProperty(value = "连续登录失败次数;")
+    private Integer loginFailureCount;
+
+    private String loginIp;
+
+    @ApiModelProperty(value = "商户报备号;")
+    private String tradeMerchantNo;
+
+    private String name;
+
+    @ApiModelProperty(value = "如果is_admined=1,说明这个账户是子账户,它的拥有者的adminId就是parent_id;")
+    private Long parentId;
+
+    private String password;
+
+    @ApiModelProperty(value = "当前查看过公告的id;")
+    private Long noticeId;
+
+    @ApiModelProperty(value = "类型,0:超管,1,公司人员;2:商家,3:商家子账户")
+    private Integer type;
+
+    @ApiModelProperty(value = "登录名;")
+    private String username;
+
+    @ApiModelProperty(value = "电话;")
+    private String phone;
+
+    @ApiModelProperty(value = "是否退款;")
+    private String isRefund;
+
+    @ApiModelProperty(value = "是否国外;0:国内,1:国外")
+    private String ifForeign;
+
+    @ApiModelProperty(value = "是否开启远程开关机")
+    private String open;
+
+    @ApiModelProperty(value = "是否开通0折优惠码;0:开通;1:关闭")
+    private String promoCodeOpen;
+
+    @ApiModelProperty(value = "机器连接服务器免审核开始时间")
+    private Date applyStartTime;
+
+    @ApiModelProperty(value = "机器连接服务器免审核结束时间")
+    private Date applyEndTime;
+
+    @ApiModelProperty(value = "短信验证码;")
+    private String code;
+
+    @ApiModelProperty(value = "支付平台; 0或null为汇聚,1为杉德支付")
+    private String payPlatform;
+
+    @ApiModelProperty(value = "关联商家,相当于以前的parent_id")
+    private String relationAdminId;
+    @Transient
+    public String getManagerId() {
+
+        String managerId = "";
+
+        managerId = AdminUtils.encrypt(false, this.getId());
+        return managerId;
+    }
+
+}

+ 27 - 0
src/main/java/com/szwl/model/query/TAdminParam.java

@@ -0,0 +1,27 @@
+package com.szwl.model.query;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.szwl.model.bo.BasePageQuery;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-03-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="查询 TAdmin", description="")
+public class TAdminParam extends BasePageQuery {
+    String name;
+}

+ 57 - 0
src/main/java/com/szwl/model/utils/AdminUtils.java

@@ -0,0 +1,57 @@
+/*
+ *
+ *
+ *
+ */
+package com.szwl.model.utils;
+
+/**
+ * 处理id
+ */
+public final class AdminUtils {
+
+    private static final Long base1 = 2452l;
+
+    private static final Long base2 = 13l;
+
+    private static final String prefix = "u";
+
+
+    /**
+     * 将id转成加密样式
+     */
+    public static String encrypt(boolean isPrefix , Long id) {
+        id = id * base2 + base1;
+        if(isPrefix){
+            return prefix + id.toString();
+        }else{
+            return id.toString();
+        }
+
+    }
+
+
+    /**
+     * 解密id
+     */
+    public static Long decrypt(boolean isPrefix , String uid) {
+        try {
+            if(isPrefix){
+                uid = uid.substring(1, uid.length());
+            }
+
+            Long id = Long.valueOf(uid);
+            id = id - base1;
+            id = id / base2;
+            return id;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(encrypt(false, 3L));
+        System.out.println(decrypt(false, "2478"));
+    }
+}

+ 117 - 0
src/main/java/com/szwl/model/utils/Base64Util.java

@@ -0,0 +1,117 @@
+package com.szwl.model.utils;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * base64 format encoding & decoding
+ */
+public class Base64Util {
+	private static char[] base64EncodeChars = new char[] { 'A', 'B', 'C', 'D',
+			'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
+			'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+			'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
+			'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+			'4', '5', '6', '7', '8', '9', '+', '/' };
+
+	private static byte[] base64DecodeChars = new byte[] { -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59,
+			60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+			10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
+			-1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+			38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1,
+			-1, -1 };
+
+	private Base64Util(){
+	}
+
+	public static String encode(byte[] data){
+		StringBuffer sb = new StringBuffer();
+		int len = data.length;
+		int i = 0;
+		int b1, b2, b3;
+
+		while (i < len) {
+			b1 = data[i++] & 0xff;
+			if (i == len) {
+				sb.append(base64EncodeChars[b1 >>> 2]);
+				sb.append(base64EncodeChars[(b1 & 0x3) << 4]);
+				sb.append("==");
+				break;
+			}
+			b2 = data[i++] & 0xff;
+			if (i == len) {
+				sb.append(base64EncodeChars[b1 >>> 2]);
+				sb.append(base64EncodeChars[((b1 & 0x03) << 4)
+						| ((b2 & 0xf0) >>> 4)]);
+				sb.append(base64EncodeChars[(b2 & 0x0f) << 2]);
+				sb.append("=");
+				break;
+			}
+			b3 = data[i++] & 0xff;
+			sb.append(base64EncodeChars[b1 >>> 2]);
+			sb.append(base64EncodeChars[((b1 & 0x03) << 4)
+					| ((b2 & 0xf0) >>> 4)]);
+			sb.append(base64EncodeChars[((b2 & 0x0f) << 2)
+					| ((b3 & 0xc0) >>> 6)]);
+			sb.append(base64EncodeChars[b3 & 0x3f]);
+		}
+		return sb.toString();
+	}
+
+	public static byte[] decode(String str){
+		byte[] data = str.getBytes();
+		int len = data.length;
+		ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
+		int i = 0;
+		int b1, b2, b3, b4;
+
+		while (i < len) {
+
+			/* b1 */
+			do {
+				b1 = base64DecodeChars[data[i++]];
+			} while (i < len && b1 == -1);
+			if (b1 == -1) {
+				break;
+			}
+
+			/* b2 */
+			do {
+				b2 = base64DecodeChars[data[i++]];
+			} while (i < len && b2 == -1);
+			if (b2 == -1) {
+				break;
+			}
+			buf.write(((b1 << 2) | ((b2 & 0x30) >>> 4)));
+
+			/* b3 */
+			do {
+				b3 = data[i++];
+				if (b3 == 61) {
+					return buf.toByteArray();
+				}
+				b3 = base64DecodeChars[b3];
+			} while (i < len && b3 == -1);
+			if (b3 == -1) {
+				break;
+			}
+			buf.write((((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2)));
+
+			/* b4 */
+			do {
+				b4 = data[i++];
+				if (b4 == 61) {
+					return buf.toByteArray();
+				}
+				b4 = base64DecodeChars[b4];
+			} while (i < len && b4 == -1);
+			if (b4 == -1) {
+				break;
+			}
+			buf.write((((b3 & 0x03) << 6) | b4));
+		}
+		return buf.toByteArray();
+	}
+}

+ 17 - 0
src/main/java/com/szwl/model/utils/CodeUtil.java

@@ -0,0 +1,17 @@
+package com.szwl.model.utils;
+
+/**
+ * 编解码工具类
+ * @author chenyf
+ * @date 2018-12-15
+ */
+public class CodeUtil {
+
+    public static String base64Encode(byte[] value) {
+        return Base64Util.encode(value);
+    }
+
+    public static byte[] base64Decode(String value) {
+        return Base64Util.decode(value);
+    }
+}

+ 74 - 0
src/main/java/com/szwl/model/utils/Constant.java

@@ -0,0 +1,74 @@
+package com.szwl.model.utils;
+
+/**
+ * Created by dinfeng 
+ */
+public class Constant {
+
+    private static double EARTH_RADIUS = 6371.393;
+    private static double rad(double d)
+    {
+        return d * Math.PI / 180.0;
+    }
+
+    /**
+     * 计算两个经纬度之间的距离
+     * @param lat1
+     * @param lng1
+     * @param lat2
+     * @param lng2
+     * @return
+     */
+    public static double GetDistance(double lat1, double lng1, double lat2, double lng2)
+    {
+        double radLat1 = rad(lat1);
+        double radLat2 = rad(lat2);
+        double a = radLat1 - radLat2;
+        double b = rad(lng1) - rad(lng2);
+        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
+                Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
+        s = s * EARTH_RADIUS;
+        s = Math.round(s * 1000);
+        return s;
+    }
+
+    /**
+     * admin 默认role id 1
+     */
+    public final static Long ROLE_ID_ADMIN = 1l;
+
+    /**
+     * 代理商 默认role id 2
+     */
+    public final static Long ROLE_ID_AGENCY= 2l;
+
+    /**
+     * 经销商 默认role id 3
+     */
+    public final static Long ROLE_ID_MERCHANT= 3l;
+
+    /**
+     * 个人商家 默认role id 4
+     */
+    public final static Long ROLE_ID_PERSONAGE= 4l;
+
+    /**
+     * 正确结果
+     */
+    public final static String correct_code = "ok";
+
+    /**
+     *
+     *
+     *
+     *      GlobalConfig
+     *
+     *
+     *
+     */
+
+    /**
+     * admin 访问码
+     */
+    public final static String ACCESS_CODE = "8";
+}

+ 266 - 0
src/main/java/com/szwl/model/utils/DateUtils.java

@@ -0,0 +1,266 @@
+package com.szwl.model.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class DateUtils
+{
+  public static final String PATTERN_MMdd = "MMdd";
+  public static final String PATTERN_yyyyMMdd = "yyyyMMdd";
+  public static final String PATTERN_yyyyMMddHHmmss = "yyyyMMddHHmmss";
+  public static final String PATTERN_yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";
+  public static final String PATTERN_yyyy_MM_dd = "yyyy-MM-dd";
+  public static final String PATTERN_yyyy_M_d = "yyyy-M-d";
+  public static final String PATTERN_yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
+  public static final String PATTERN_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
+  public static final String PATTERN_HH_mm_ss = "HH:mm:ss";
+  public static final String PATTERN_HHmmss = "HHmmss";
+  public static final String PATTERN_HH = "HH";
+  public static final String PATTERN_MMdd2 = "MM月dd";
+  public static final String PATTERN_MM = "MM";
+  public static final Map<String, String> mapChDate = new HashMap<String, String>();
+
+  public static Date getNextday(Date now)
+  {
+    Calendar calendar = Calendar.getInstance();
+    calendar.setTime(now);
+    calendar.add(5, 1);
+    return calendar.getTime();
+  }
+  
+  public static Date getPreday(Date now)
+  {
+    Calendar calendar = Calendar.getInstance();
+    calendar.setTime(now);
+    calendar.add(5, -1);
+    return calendar.getTime();
+  }
+
+  public static String formatDate_ch(Date date)
+  {
+    if(date==null){
+   	 throw new IllegalArgumentException("需要转换的对象为空");
+    }
+    String str = formatDate(date, "MMdd");
+    str = (String)mapChDate.get(str.substring(0, 2)) + str.substring(2);
+    return str;
+  }
+
+  public static String formatDate(Date date, String pattern)
+  {
+    if(date==null){
+        return "";
+    }
+    SimpleDateFormat sdf = null;
+    if (pattern == null)
+      sdf = new SimpleDateFormat();
+    else {
+      sdf = new SimpleDateFormat(pattern);
+    }
+    return sdf.format(date);
+  }
+
+  public static String formatDate(Date date) {
+    SimpleDateFormat sdf = new SimpleDateFormat();
+    return sdf.format(date);
+  }
+
+  public static Date parseDate(String source, String pattern) throws ParseException
+  {
+    SimpleDateFormat sdf = null;
+    if (pattern == null)
+      sdf = new SimpleDateFormat();
+    else {
+      sdf = new SimpleDateFormat(pattern);
+    }
+    return sdf.parse(source);
+  }
+
+  public static Date parseDate(String source) throws ParseException {
+    SimpleDateFormat sdf = new SimpleDateFormat();
+    return sdf.parse(source);
+  }
+
+  public static Date parseDate(String source, Date defaultDate) {
+    try {
+      SimpleDateFormat sdf = new SimpleDateFormat();
+      return sdf.parse(source);
+    }
+    catch (ParseException e)
+    {
+    }
+    return defaultDate;
+  }
+
+  public static Date parseDate(String source, String pattern, Date defaultDate) {
+    try {
+      SimpleDateFormat sdf = null;
+      if (pattern == null)
+        sdf = new SimpleDateFormat();
+      else {
+        sdf = new SimpleDateFormat(pattern);
+      }
+      return sdf.parse(source);
+    }
+    catch (ParseException e) {
+    }
+    return defaultDate;
+  }
+
+  public static boolean tryParse(String source) throws ParseException {
+    try {
+      Integer.parseInt(source);
+      return true;
+    } catch (NumberFormatException e) {
+    }
+    return false;
+  }
+
+  public static Date changeDate(Date date, TimeType timeType, int amount)
+  {
+    if ((date == null) || (timeType == null) || (amount == 0)) {
+      return date;
+    }
+    Calendar c = Calendar.getInstance();
+    c.setTime(date);
+    c.add(timeType.getValue(), amount);
+    return c.getTime();
+  }
+
+  public static boolean isSameDay(Date date1, Date date2)
+  {
+    if ((date1 == null) || (date2 == null)) {
+      throw new IllegalArgumentException("The date must not be null");
+    }
+    Calendar cal1 = Calendar.getInstance();
+    cal1.setTime(date1);
+    Calendar cal2 = Calendar.getInstance();
+    cal2.setTime(date2);
+    return isSameDay(cal1, cal2);
+  }
+
+  public static boolean isSameDay(Calendar cal1, Calendar cal2)
+  {
+    if ((cal1 == null) || (cal2 == null)) {
+      throw new IllegalArgumentException("The date must not be null");
+    }
+    return (cal1.get(0) == cal2.get(0)) && (cal1.get(1) == cal2.get(1)) && (cal1.get(6) == cal2.get(6));
+  }
+
+  /** @deprecated */
+  public static Date add(Date date, int calendarField, int amount)
+  {
+    if (date == null) {
+      throw new IllegalArgumentException("The date must not be null");
+    }
+    Calendar c = Calendar.getInstance();
+    c.setTime(date);
+    c.add(calendarField, amount);
+    return c.getTime();
+  }
+
+  public static Date addYears(Date date, int amount)
+  {
+    return add(date, 1, amount);
+  }
+
+  public static Date addMonths(Date date, int amount)
+  {
+    return add(date, 2, amount);
+  }
+
+  public static Date addWeeks(Date date, int amount)
+  {
+    return add(date, 3, amount);
+  }
+
+  public static Date addDays(Date date, int amount)
+  {
+    return add(date, 5, amount);
+  }
+
+  public static Date addHours(Date date, int amount)
+  {
+    return add(date, 11, amount);
+  }
+
+  public static Date addMinutes(Date date, int amount)
+  {
+    return add(date, 12, amount);
+  }
+
+  public static Date addSeconds(Date date, int amount)
+  {
+    return add(date, 13, amount);
+  }
+
+  public static Date addMilliseconds(Date date, int amount)
+  {
+    return add(date, 14, amount);
+  }
+
+  static
+  {
+    mapChDate.put("01", "一月");
+    mapChDate.put("02", "二月");
+    mapChDate.put("03", "三月");
+    mapChDate.put("04", "四月");
+    mapChDate.put("05", "五月");
+    mapChDate.put("06", "六月");
+    mapChDate.put("07", "七月");
+    mapChDate.put("08", "八月");
+    mapChDate.put("09", "九月");
+    mapChDate.put("10", "十月");
+    mapChDate.put("11", "十一月");
+    mapChDate.put("12", "十二月");
+  }
+
+  public static enum TimeType
+  {
+    SECOND(13), MINUTE(12), HOUR(10), DAY(5), 
+    WEEK(4), MONTH(2), 
+    YEAR(1);
+
+    private int value;
+
+    private TimeType(int value) {
+      this.value = value;
+    }
+
+    public int getValue() {
+      return this.value;
+    }
+  }
+  /**
+   * 
+   * 毛龙飞
+   * @Description 获取日期的后几天
+   * @param d
+   * @param day
+   * @return
+   */
+  public static Date getDateAfter(Date d, int day) {  
+      Calendar now = Calendar.getInstance();  
+      now.setTime(d);  
+      now.set(Calendar.DATE, now.get(Calendar.DATE) + day);  
+      return now.getTime();  
+  }
+
+  /**
+   * 获取week 0是周日
+   * @param day
+   * @return
+   */
+  public static int getWeek(Date day) {
+    Calendar cal = Calendar.getInstance();
+    cal.setTime(day);
+    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+    if (w < 0)
+      w = 0;
+    return w;
+  }
+}

+ 396 - 0
src/main/java/com/szwl/model/utils/Filter.java

@@ -0,0 +1,396 @@
+/*
+ * 
+ * 
+ * 
+ */
+package com.szwl.model.utils;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+import java.io.Serializable;
+
+/**
+ * 筛选
+ *
+ *
+ *
+ */
+public class Filter implements Serializable {
+
+    private static final long serialVersionUID = -8712382358441065075L;
+
+
+
+    /**
+     * 运算符
+     */
+    public enum Operator {
+
+        /** 等于 */
+        eq,
+
+        /** 不等于 */
+        ne,
+
+        /** 大于 */
+        gt,
+
+        /** 小于 */
+        lt,
+
+        /** 大于等于 */
+        ge,
+        geDate,
+        /** 小于等于 */
+        le,
+        leDate,
+        /** 相似 */
+        like,
+
+        /** 包含 */
+        in,
+
+        /** 为Null */
+        isNull,
+
+        /** 不为Null */
+        isNotNull;
+
+        /**
+         * 从String中获取Operator
+         *
+         * @param value
+         *            值
+         * @return String对应的operator
+         */
+        public static Operator fromString(String value) {
+            return Operator.valueOf(value.toLowerCase());
+        }
+    }
+
+    /** 默认是否忽略大小写 */
+    private static final boolean DEFAULT_IGNORE_CASE = false;
+
+    /** 属性 */
+    private String property;
+
+    /** 运算符 */
+    private Operator operator;
+
+    /** 值 */
+    private Object value;
+
+    /** 是否忽略大小写 */
+    private Boolean ignoreCase = DEFAULT_IGNORE_CASE;
+
+    /**
+     * 初始化一个新创建的Filter对象
+     */
+    public Filter() {
+    }
+
+    /**
+     * 初始化一个新创建的Filter对象
+     *
+     * @param property
+     *            属性
+     * @param operator
+     *            运算符
+     * @param value
+     *            值
+     */
+    public Filter(String property, Operator operator, Object value) {
+        this.property = property;
+        this.operator = operator;
+        this.value = value;
+    }
+
+    /**
+     * 初始化一个新创建的Filter对象
+     *
+     * @param property
+     *            属性
+     * @param operator
+     *            运算符
+     * @param value
+     *            值
+     * @param ignoreCase
+     *            忽略大小写
+     */
+    public Filter(String property, Operator operator, Object value, boolean ignoreCase) {
+        this.property = property;
+        this.operator = operator;
+        this.value = value;
+        this.ignoreCase = ignoreCase;
+    }
+
+    /**
+     * 返回等于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 等于筛选
+     */
+    public static Filter eq(String property, Object value) {
+        return new Filter(property, Operator.eq, value);
+    }
+
+    /**
+     * 返回等于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @param ignoreCase
+     *            忽略大小写
+     * @return 等于筛选
+     */
+    public static Filter eq(String property, Object value, boolean ignoreCase) {
+        return new Filter(property, Operator.eq, value, ignoreCase);
+    }
+
+    /**
+     * 返回不等于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 不等于筛选
+     */
+    public static Filter ne(String property, Object value) {
+        return new Filter(property, Operator.ne, value);
+    }
+
+    /**
+     * 返回不等于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @param ignoreCase
+     *            忽略大小写
+     * @return 不等于筛选
+     */
+    public static Filter ne(String property, Object value, boolean ignoreCase) {
+        return new Filter(property, Operator.ne, value, ignoreCase);
+    }
+
+    /**
+     * 返回大于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 大于筛选
+     */
+    public static Filter gt(String property, Object value) {
+        return new Filter(property, Operator.gt, value);
+    }
+
+    /**
+     * 返回小于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 小于筛选
+     */
+    public static Filter lt(String property, Object value) {
+        return new Filter(property, Operator.lt, value);
+    }
+
+    /**
+     * 返回大于等于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 大于等于筛选
+     */
+    public static Filter ge(String property, Object value) {
+        return new Filter(property, Operator.ge, value);
+    }
+
+    public static Filter geDate(String property, Object value) {
+        return new Filter(property, Operator.geDate, value);
+    }
+    /**
+     * 返回小于等于筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 小于等于筛选
+     */
+    public static Filter le(String property, Object value) {
+        return new Filter(property, Operator.le, value);
+    }
+    public static Filter leDate(String property, Object value) {
+        return new Filter(property, Operator.leDate, value);
+    }
+
+    /**
+     * 返回相似筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 相似筛选
+     */
+    public static Filter like(String property, Object value) {
+        return new Filter(property, Operator.like, value);
+    }
+
+    /**
+     * 返回包含筛选
+     *
+     * @param property
+     *            属性
+     * @param value
+     *            值
+     * @return 包含筛选
+     */
+    public static Filter in(String property, Object value) {
+        return new Filter(property, Operator.in, value);
+    }
+
+    /**
+     * 返回为Null筛选
+     *
+     * @param property
+     *            属性
+     * @return 为Null筛选
+     */
+    public static Filter isNull(String property) {
+        return new Filter(property, Operator.isNull, null);
+    }
+
+    /**
+     * 返回不为Null筛选
+     *
+     * @param property
+     *            属性
+     * @return 不为Null筛选
+     */
+    public static Filter isNotNull(String property) {
+        return new Filter(property, Operator.isNotNull, null);
+    }
+
+    /**
+     * 返回忽略大小写筛选
+     *
+     * @return 忽略大小写筛选
+     */
+    public Filter ignoreCase() {
+        this.ignoreCase = true;
+        return this;
+    }
+
+    /**
+     * 获取属性
+     *
+     * @return 属性
+     */
+    public String getProperty() {
+        return property;
+    }
+
+    /**
+     * 设置属性
+     *
+     * @param property
+     *            属性
+     */
+    public void setProperty(String property) {
+        this.property = property;
+    }
+
+    /**
+     * 获取运算符
+     *
+     * @return 运算符
+     */
+    public Operator getOperator() {
+        return operator;
+    }
+
+    /**
+     * 设置运算符
+     *
+     * @param operator
+     *            运算符
+     */
+    public void setOperator(Operator operator) {
+        this.operator = operator;
+    }
+
+    /**
+     * 获取值
+     *
+     * @return 值
+     */
+    public Object getValue() {
+        return value;
+    }
+
+    /**
+     * 设置值
+     *
+     * @param value
+     *            值
+     */
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    /**
+     * 获取是否忽略大小写
+     *
+     * @return 是否忽略大小写
+     */
+    public Boolean getIgnoreCase() {
+        return ignoreCase;
+    }
+
+    /**
+     * 设置是否忽略大小写
+     *
+     * @param ignoreCase
+     *            是否忽略大小写
+     */
+    public void setIgnoreCase(Boolean ignoreCase) {
+        this.ignoreCase = ignoreCase;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        if (this == obj) {
+            return true;
+        }
+        Filter other = (Filter) obj;
+        return new EqualsBuilder().append(getProperty(), other.getProperty()).append(getOperator(), other.getOperator()).append(getValue(), other.getValue()).isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 37).append(getProperty()).append(getOperator()).append(getValue()).toHashCode();
+    }
+
+}

+ 332 - 0
src/main/java/com/szwl/model/utils/HttpClientUtils.java

@@ -0,0 +1,332 @@
+package com.szwl.model.utils;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.ConnectionConfig;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by study on 6/26/2015 11:30.
+ */
+public final class HttpClientUtils {
+    private static Logger logger = Logger.getLogger("HttpClientUtils");
+    public final static String Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getOrder";
+    public final static String Update_Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/updateOrder";
+//    public final static String Es_Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getOrder";
+    public final static String CoinOrder_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getCoinOrder";
+//    public final static String Es_CoinOrder_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getCoinOrder";
+public final static String Equipment_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getEquipment";
+    public final static String Update_Equipment_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/updateEquipment";
+    private HttpClientUtils() {
+    }
+
+    /**
+     * post xml
+     *
+     * @param url
+     * @param xml
+     * @return
+     */
+    public static String postXml(String url, String xml) throws IOException {
+        HttpClient client = HttpClientBuilder.create().build();
+        client = WebClientDevWrapper.wrapClient(client);
+        HttpPost post = new HttpPost(url);
+        String response = null;
+        InputStream instream = null;
+        try {
+            StringEntity s = new StringEntity(xml, "UTF-8");
+            s.setContentEncoding("UTF-8");
+            s.setContentType("application/xml");
+            post.setEntity(s);
+            HttpResponse res = null;
+            if (client != null) {
+                res = client.execute(post);
+            }
+            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = res.getEntity();
+                SAXReader reader = new SAXReader();
+                instream = entity.getContent();
+                Document document = reader.read(new InputStreamReader(instream, "utf-8"));
+                response = document.asXML();
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (instream != null) {
+                instream.close();
+            }
+        }
+        return response;
+    }
+
+    /**
+     * post json
+     *
+     * @param url
+     * @param json
+     * @return
+     */
+    public static JSONObject postJson(String url, String json) throws IOException {
+        HttpClient client = HttpClientBuilder.create().build();
+        client = WebClientDevWrapper.wrapClient(client);
+        HttpPost post = new HttpPost(url);
+        JSONObject response = null;
+        InputStream instream = null;
+        try {
+            StringEntity s = new StringEntity(json, "UTF-8");
+            s.setContentEncoding("UTF-8");
+            s.setContentType("application/json");
+            post.setEntity(s);
+            HttpResponse res = null;
+            if (client != null) {
+                res = client.execute(post);
+            }
+            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = res.getEntity();
+                String charset = "utf-8";
+                instream = entity.getContent();
+                response = new JSONObject(new JSONTokener(new InputStreamReader(instream, charset)));
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (instream != null) {
+                instream.close();
+            }
+        }
+        return response;
+    }
+
+
+    /**
+     * java httpClient4.5 post请求
+     */
+    @SuppressWarnings("unchecked")
+    public static String sendPost(String sendMsg, String sendUrl) {
+        HttpPost httpPost = new HttpPost(sendUrl);
+        HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
+        CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
+        StringEntity entity;
+        String status = "false";
+        Map<String,Object> mres = new HashMap<String, Object>();
+        try {
+            entity = new StringEntity(sendMsg, "UTF-8"); //解决参数中文乱码问题
+            entity.setContentEncoding("UTF-8");//设置编码格式
+            entity.setContentType("application/json");
+            httpPost.setEntity(entity);
+            // 发起请求
+            HttpResponse httpResponse = closeableHttpClient.execute(httpPost);
+            // 请求结束,返回结果。并解析json。
+            String resData = EntityUtils.toString(httpResponse.getEntity(),"UTF-8");
+            status = resData;
+//            Map map = JSON.parseObject(JSON.toJSONString(resData), Map.class);
+//            mres = (Map<String, Object>) JSON.parseObject(JSON.toJSONString(resData), Map.class);
+//            mres = (Map<String, Object>) JSONObject.toBean(JSONObject.fromObject(resData), Map.class);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (null != closeableHttpClient) {
+                try {
+                    closeableHttpClient.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return status;
+//        return mres;
+    }
+    /**
+     * post 键值对
+     *
+     * @param url
+     * @param data 键值对内容
+     * @return
+     */
+    public static String sentData(String url, String data) {
+        if(!StringUtils.isEmpty(url)&&!StringUtils.isEmpty(data)){
+            String result = sendPost(data, url);
+            return result;
+        }
+        return "400";
+    }
+
+    /**
+     * post 键值对
+     *
+     * @param url
+     * @param data 键值对内容
+     * @return
+     */
+    public static String postKeyValue(String url, List<BasicNameValuePair> data) {
+
+
+        CloseableHttpClient httpClient = getHttpClient();
+        try {
+            HttpPost post = new HttpPost(url);
+
+
+            //url格式编码
+            UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(data, "UTF-8");
+            post.setEntity(uefEntity);
+            CloseableHttpResponse httpResponse = httpClient.execute(post);
+            HttpEntity entity = httpResponse.getEntity();
+            try {
+                if (null != entity) {
+                    String result = EntityUtils.toString(entity);
+                    return result;
+                }
+            } finally {
+                httpResponse.close();
+            }
+
+
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                closeHttpClient(httpClient);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * get json
+     *
+     * @param url
+     * @return
+     */
+    public static JSONObject get(String url) throws IOException {
+        HttpClient client = HttpClientBuilder.create().build();
+        client = WebClientDevWrapper.wrapClient(client);
+        HttpGet get = new HttpGet(url);
+        JSONObject response = null;
+        InputStream instream = null;
+        try {
+            HttpResponse res = null;
+            if (client != null) {
+                res = client.execute(get);
+            }
+            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = res.getEntity();
+                instream = entity.getContent();
+                response = new JSONObject(new JSONTokener(new InputStreamReader(instream, "utf-8")));
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (instream != null) {
+                instream.close();
+            }
+        }
+        return response;
+    }
+
+    private static class WebClientDevWrapper {
+        public static HttpClient wrapClient(HttpClient base) {
+            try {
+                RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.create();
+                ConnectionSocketFactory plainSF = new PlainConnectionSocketFactory();
+                registryBuilder.register("http", plainSF);
+                //指定信任密钥存储对象和连接套接字工厂
+                try {
+                    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+                    SSLContext sslContext = SSLContexts.custom().useTLS().loadTrustMaterial(trustStore, new AnyTrustStrategy()).build();
+                    LayeredConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+                    registryBuilder.register("https", sslSF);
+                } catch (KeyStoreException e) {
+                    throw new RuntimeException(e);
+                } catch (KeyManagementException e) {
+                    throw new RuntimeException(e);
+                } catch (NoSuchAlgorithmException e) {
+                    throw new RuntimeException(e);
+                }
+                Registry<ConnectionSocketFactory> registry = registryBuilder.build();
+                //设置连接管理器
+                PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(registry);
+                connManager.setDefaultConnectionConfig(ConnectionConfig.custom().setCharset(Charset.forName("UTF-8")).build());
+                connManager.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(100000).build());
+                //构建客户端
+                return HttpClientBuilder.create().setConnectionManager(connManager).build();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            return null;
+        }
+
+        private static class AnyTrustStrategy implements TrustStrategy {
+            @Override
+            public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+                return true;
+            }
+        }
+
+
+    }
+
+
+    private static CloseableHttpClient getHttpClient() {
+        return HttpClients.createDefault();
+    }
+
+    private static void closeHttpClient(CloseableHttpClient client) throws IOException {
+        if (client != null) {
+            client.close();
+        }
+    }
+
+}

+ 270 - 0
src/main/java/com/szwl/model/utils/JoinpayConstant.java

@@ -0,0 +1,270 @@
+package com.szwl.model.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 汇聚支付 常量
+ */
+public class JoinpayConstant {
+
+
+    /**
+     * 商户编码
+     */
+    public final static String mch_no = "888106600000003";
+
+
+    /**
+     * 商户密钥 : MD5
+     */
+    public final static String key = "8cb1d25eba7d4f3caecf1f0569150e04";
+
+
+    /**
+     * 汇聚公钥
+     */
+    public final static String publickey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCLgawJlQ3O8/O9YmJt6mi0pzh9JiDGp2G6IW3p8NTZXE5tIBZRbQAkHnr/zaLh0kDHMtIGAcGUtgXilRxXeUIuc0/j561YLsxAORma2XerniRCLWrXS4yM8F1/813Rv21JoNFkDZWHdTgEpKTH8GaGYOHiEytIN0LvPzEvNsimWQIDAQAB";
+
+    /**
+     * >>>>>>>>>>>>> 币种 >>>>>>>>>>>>>
+     *
+     */
+    /**
+     * 人民币
+     */
+    public final static String Cur_RMB = "1";
+
+
+    /**
+     *  支付成功回调
+     */
+//    public final static String Notify_Url = "http://pay.sunzee.com.cn:49013/tOrder/notify";
+    public final static String Notify_Url = "http://szwltest.sunzee.com.cn:49002/PAY-SERVER/tOrder/notify";
+//    public final static String Notify_Url = "http://slb.sunzee.com.cn/api/order/notify.htm";
+
+    public final static String mg280Notify_Url = "http://pay.sunzee.com.cn:49013/tOrder/mg280Notify";
+//    public final static String mg280Notify_Url = "http://slb.sunzee.com.cn/api/order/mg280Notify.htm";
+
+    public final static String Notify_Url_PromoCode = "http://pay.sunzee.com.cn:49013/tOrder/promoCodeNotify";
+//    public final static String Notify_Url_PromoCode = "http://slb.sunzee.com.cn/api/order/promoCodeNotify.htm";
+
+    public final static String Jiesuan_Url = "http://app.sunzee.com.cn/api/order/jiesuan";
+//    public final static String Jiesuan_Url = "http://slb.sunzee.com.cn/api/order/jiesuan.htm";
+
+    public final static Map<String,String> Result_status = new HashMap<>();
+    /**
+     *  退款成功回调
+     */
+    public final static String Notify_Refund_Url = "http://app.sunzee.com.cn/api/order/notifyRefund";
+    public final static String Admin_Notify_Refund_Url = "http://app.sunzee.com.cn/api/order/adminNotifyRefund";
+
+
+    /**
+     * 支付回调支付状态代码
+     */
+    public final static String r6_Status_100 = "100";
+    public final static String r6_Status_101 = "101";
+
+    /**
+     * >>>>>>>>>>>>> 签名类型 >>>>>>>>>>>>>
+     * 1=MD5,2=RSA
+     */
+    public final static String sign_type_MD5 = "1";
+    public final static String sign_type_RSA = "2";
+
+
+    /**
+     * >>>>>>>>>>>>> 分账方商户类型 >>>>>>>>>>>>>
+     * 10:个人,11:个体工商户,12:企业
+     */
+    public final static Integer alt_merchant_type1 = 10;
+    public final static Integer alt_merchant_type2 = 11;
+    public final static Integer alt_merchant_type3 = 12;
+
+    /**
+     * >>>>>>>>>>>>> 分账方结算方式 >>>>>>>>>>>>>
+     * 1 由汇聚自动结算
+     * 2 由商户平台手工结算(结算接口)
+     */
+    public final static Integer sett_mode1 = 1;
+    public final static Integer sett_mode2 = 2;
+
+
+    /**
+     * >>>>>>>>>>>>> 结算周期类型 >>>>>>>>>>>>>
+     * 1 工作日,2 自然日,3 月结日
+     */
+    public final static Integer sett_date_type1 = 1;
+    public final static Integer sett_date_type2 = 2;
+    public final static Integer sett_date_type3 = 3;
+
+
+    /**
+     * >>>>>>>>>>>>> 账户类型 >>>>>>>>>>>>>
+     * 1 借记卡,4 对公账户
+     */
+    public final static Integer bank_account_type1 = 1;
+    public final static Integer bank_account_type4 = 4;
+
+
+    /**
+     *
+     *
+     *  >>>>>>>>>>>>> 响应码 >>>>>>>>>>>>>
+     *
+     *
+     */
+
+    /**
+     * 受理响应码
+     */
+    public static final Map<String, String> resp_code = new HashMap<>();
+    public static final String resp_code1 = "A1000";
+    public static final String resp_code2 = "A2000";
+    public static final String resp_code3 = "A3000";
+
+    static {
+        resp_code.put(resp_code1, "受理成功");
+        resp_code.put(resp_code2, "受理失败,具体失败原因查看业务响应码");
+        resp_code.put(resp_code3, "受理未知(如:接口调用超时)");
+    }
+
+    /**
+     * 商户状态
+     */
+    public static final Map<String, String> order_status = new HashMap<>();
+    public static final String order_status1 = "P0001";
+    public static final String order_status2 = "P1000";
+    public static final String order_status3 = "P2000";
+    public static final String order_status4 = "P3000";
+    public static final String order_status5 = "P3001";
+    public static final String order_status6 = "P3002";
+    public static final String order_status7 = "P3003";
+
+    static {
+        order_status.put(order_status1, "待处理中(受理中)");
+        order_status.put(order_status2, "交易成功");
+        order_status.put(order_status3, "交易失败");
+        order_status.put(order_status4, "结果未知");
+        order_status.put(order_status5, "处理中");
+        order_status.put(order_status6, "激活");
+        order_status.put(order_status7, "冻结");
+    }
+
+    /**
+     * 业务响应码
+     */
+    public static final Map<String, String> biz_code = new HashMap<>();
+    public static final String biz_code1 = "B100000";
+    public static final String biz_code2 = "B100001";
+    public static final String biz_code3 = "B100002";
+    public static final String biz_code4 = "B100003";
+    public static final String biz_code5 = "B101001";
+    public static final String biz_code6 = "B101002";
+    public static final String biz_code7 = "B101003";
+    public static final String biz_code8 = "B101004";
+    public static final String biz_code9 = "B101005";
+    public static final String biz_code10 = "B103012";
+    public static final String biz_code11 = "B103013";
+    public static final String biz_code12 = "B102001";
+
+    static {
+        biz_code.put(biz_code1, "受理成功");
+        biz_code.put(biz_code2, "验签失败");
+        biz_code.put(biz_code3, "验参失败");
+        biz_code.put(biz_code4, "结果未知,SYS_ERROR");
+        biz_code.put(biz_code5, "登录名已存在");
+        biz_code.put(biz_code6, "找不到卡bin");
+        biz_code.put(biz_code7, "联行号有误");
+        biz_code.put(biz_code8, "查找不到银行信息");
+        biz_code.put(biz_code9, "不支持的结算卡类型");
+        biz_code.put(biz_code10, "担保账户不存在");
+        biz_code.put(biz_code11, "担保账户余额不足");
+        biz_code.put(biz_code12, "分账方不存在");
+    }
+
+
+    /**
+     * >>>>>>>>>>>>> 支付交易类型 >>>>>>>>>>>>>
+     */
+    public static final Map<String, String> frp_code = new HashMap<>();
+    public static final String frp_code_ALIPAY_NATIVE = "ALIPAY_NATIVE";
+    public static final String frp_code_ALIPAY_CARD = "ALIPAY_CARD";
+    public static final String frp_code_ALIPAY_APP = "ALIPAY_APP";
+    public static final String frp_code_ALIPAY_H5 = "ALIPAY_H5";
+    public static final String frp_code_ALIPAY_FWC = "ALIPAY_FWC";
+    public static final String frp_code_ALIPAY_SYT = "ALIPAY_SYT";
+    public static final String frp_code_WEIXIN_NATIVE = "WEIXIN_NATIVE";
+    public static final String frp_code_WEIXIN_CARD = "WEIXIN_CARD";
+    public static final String frp_code_WEIXIN_APP = "WEIXIN_APP";
+    public static final String frp_code_WEIXIN_APP2 = "WEIXIN_APP2";
+    public static final String frp_code_WEIXIN_H5 = "WEIXIN_H5";
+    public static final String frp_code_WEIXIN_GZH = "WEIXIN_GZH";
+    public static final String frp_code_WEIXIN_XCX = "WEIXIN_XCX";
+    public static final String frp_code_JD_NATIVE = "JD_NATIVE";
+    public static final String frp_code_JD_CARD = "JD_CARD";
+    public static final String frp_code_JD_APP = "JD_APP";
+    public static final String frp_code_JD_H5 = "JD_H5";
+    public static final String frp_code_QQ_NATIVE = "QQ_NATIVE";
+    public static final String frp_code_QQ_CARD = "QQ_CARD";
+    public static final String frp_code_QQ_APP = "QQ_APP";
+    public static final String frp_code_QQ_H5 = "QQ_H5";
+    public static final String frp_code_QQ_GZH = "QQ_GZH";
+    public static final String frp_code_UNIONPAY_NATIVE = "UNIONPAY_NATIVE";
+    public static final String frp_code_UNIONPAY_CARD = "UNIONPAY_CARD";
+    public static final String frp_code_UNIONPAY_APP = "UNIONPAY_APP";
+    public static final String frp_code_UNIONPAY_H5 = "UNIONPAY_H5";
+    public static final String frp_code_BAIDU_NATIVE = "BAIDU_NATIVE";
+    public static final String frp_code_SUNING_NATIVE = "SUNING_NATIVE";
+
+
+    static {
+        biz_code.put(frp_code_ALIPAY_NATIVE, "支付宝扫码(主扫)");
+        biz_code.put(frp_code_ALIPAY_CARD, "支付宝刷卡(被扫)");
+        biz_code.put(frp_code_ALIPAY_APP, "支付宝APP 支付");
+        biz_code.put(frp_code_ALIPAY_H5, "支付宝H5");
+        biz_code.put(frp_code_ALIPAY_FWC, "支付宝服务窗");
+        biz_code.put(frp_code_ALIPAY_SYT, "支付宝收银台");
+        biz_code.put(frp_code_WEIXIN_NATIVE, "微信扫码(主扫)");
+        biz_code.put(frp_code_WEIXIN_CARD, "微信刷卡(被扫)");
+        biz_code.put(frp_code_WEIXIN_APP, "微信APP 支付");
+        biz_code.put(frp_code_WEIXIN_APP2, "微信APP2 支付");
+        biz_code.put(frp_code_WEIXIN_H5, "微信H5 支付");
+        biz_code.put(frp_code_WEIXIN_GZH, "微信公众号支付");
+        biz_code.put(frp_code_WEIXIN_XCX, "微信小程序支付");
+        biz_code.put(frp_code_JD_NATIVE, "京东扫码(主扫)");
+        biz_code.put(frp_code_JD_CARD, "京东刷卡(被扫)");
+        biz_code.put(frp_code_JD_APP, "京东APP 支付");
+        biz_code.put(frp_code_JD_H5, "京东H5 支付");
+        biz_code.put(frp_code_QQ_NATIVE, "QQ 扫码(主扫)");
+        biz_code.put(frp_code_QQ_CARD, "QQ 刷卡(被扫)");
+        biz_code.put(frp_code_QQ_APP, "QQ APP 支付");
+        biz_code.put(frp_code_QQ_H5, "QQH5 支付");
+        biz_code.put(frp_code_QQ_GZH, "QQ 公众号支付");
+        biz_code.put(frp_code_UNIONPAY_NATIVE, "银联扫码(主扫)");
+        biz_code.put(frp_code_UNIONPAY_CARD, "银联刷卡(被扫)");
+        biz_code.put(frp_code_UNIONPAY_APP, "银联APP 支付");
+        biz_code.put(frp_code_UNIONPAY_H5, "银联H5");
+        biz_code.put(frp_code_BAIDU_NATIVE, "百度扫码(主扫)");
+        biz_code.put(frp_code_SUNING_NATIVE, "苏宁扫码(主扫)");
+    }
+
+
+    /**
+     *
+     *
+     *  >>>>>>>>>>>>> 汇聚支付接口 >>>>>>>>>>>>>
+     *
+     *
+     */
+
+    /**
+     * 版本
+     */
+    public static final String pay_version = "1.0";
+
+
+
+
+}

+ 136 - 0
src/main/java/com/szwl/model/utils/JsonUtils.java

@@ -0,0 +1,136 @@
+/*
+ * 
+ * 
+ * 
+ */
+package com.szwl.model.utils;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.gexin.fastjson.JSONObject;
+import com.gexin.fastjson.serializer.SimplePropertyPreFilter;
+import org.springframework.util.Assert;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Utils - JSON
+ */
+public final class JsonUtils {
+
+    /**
+     * ObjectMapper
+     */
+    private static ObjectMapper mapper = new ObjectMapper();
+
+    /**
+     * 不可实例化
+     */
+    private JsonUtils() {
+    }
+
+    /**
+     * 将对象转换为JSON字符串
+     *
+     * @param value 对象
+     * @return JSOn字符串
+     */
+    public static String toJson(Object value) {
+        try {
+            return mapper.writeValueAsString(value);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 将JSON字符串转换为对象
+     *
+     * @param json      JSON字符串
+     * @param valueType 对象类型
+     * @return 对象
+     */
+    public static <T> T toObject(String json, Class<T> valueType) {
+        Assert.hasText(json);
+        Assert.notNull(valueType);
+        try {
+            return mapper.readValue(json, valueType);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 将对象转成JSON
+     *
+     * @param object 对象
+     * @param attrs  包含的属性值
+     * @return 对象
+     */
+    public static String toString(Object object, String... attrs) {
+        SimplePropertyPreFilter filter = new SimplePropertyPreFilter(object.getClass(), attrs);
+        return JSONObject.toJSONString(object, filter);
+    }
+
+    /**
+     * 将JSON字符串转换为对象
+     *
+     * @param json          JSON字符串
+     * @param typeReference 对象类型
+     * @return 对象
+     */
+//    public static <T> T toObject(String json, TypeReference<?> typeReference) {
+//        Assert.hasText(json);
+//        Assert.notNull(typeReference);
+//        try {
+//            return mapper.readValue(json, typeReference);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return null;
+//    }
+
+    /**
+     * 将JSON字符串转换为对象
+     *
+     * @param json     JSON字符串
+     * @param javaType 对象类型
+     * @return 对象
+     */
+    public static <T> T toObject(String json, JavaType javaType) {
+        Assert.hasText(json);
+        Assert.notNull(javaType);
+        try {
+            return mapper.readValue(json, javaType);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 将对象转换为JSON流
+     *
+     * @param writer writer
+     * @param value  对象
+     */
+    public static void writeValue(Writer writer, Object value) {
+        try {
+            mapper.writeValue(writer, value);
+        } catch (JsonGenerationException e) {
+            e.printStackTrace();
+        } catch (JsonMappingException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+}

+ 293 - 0
src/main/java/com/szwl/model/utils/PushUtils.java

@@ -0,0 +1,293 @@
+package com.szwl.model.utils;
+
+import com.gexin.rp.sdk.base.impl.SingleMessage;
+import com.gexin.rp.sdk.base.impl.Target;
+import com.gexin.rp.sdk.base.payload.APNPayload;
+import com.gexin.rp.sdk.exceptions.RequestException;
+import com.gexin.rp.sdk.http.IGtPush;
+import com.gexin.rp.sdk.template.TransmissionTemplate;
+import org.json.JSONObject;
+
+import java.util.List;
+
+/**
+ * Created by dinfeng on 2017/12/21
+ * 个推工具类
+ */
+public class PushUtils {
+
+
+    public final static String appId = "GKa6qa12heALjEXZlAn1U3";
+
+    public final static String appKey = "fLvPjR8hni7VFMkgjh8lx2";
+
+    public final static String masterSecret = "KjxrC6vTLr5wiZu55cCnS8";
+
+    public final static String host = "http://sdk.open.api.igexin.com/apiex.htm";
+
+//    public  static IPushResult rets =null;
+
+    public static String test_clientId = "c69869085580f3b77f2972403fbdd5b3";
+    public static String test_clientId2 = "200cb24ae7af3c4096cc2c46569ed530";
+
+
+    final static IGtPush push = new IGtPush(host, appKey, masterSecret);
+
+//    private static EquipmentService equipmentService;
+//
+//    @Autowired
+//    public PushUtils(EquipmentService equipmentService) {
+//        PushUtils.equipmentService = equipmentService;
+//    }
+//    private static RabbitTemplate rabbitTemplate;
+//
+//    @Autowired
+//    public PushUtils(RabbitTemplate rabbitTemplate) {
+//        PushUtils.rabbitTemplate = rabbitTemplate;
+//    }
+
+    /**
+     * 个推发送信息
+     *
+     * @param clientIds   设备号数组
+     * @param title
+     * @param information 信息
+     * @param json        业务id
+     */
+    public static void push(List<String> clientIds, String title, String information, String json) {
+
+
+        TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
+        //推送ios
+        final SingleMessage iMessage = new SingleMessage();
+        iMessage.setOffline(true);
+        // 离线有效时间,单位为毫秒,可选
+        iMessage.setOfflineExpireTime(24 * 3600 * 1000);
+        iMessage.setData(transmissionTemplate);
+        // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
+        iMessage.setPushNetWorkType(0);
+
+        //个推
+        for (String clientId : clientIds) {
+            final Target target = new Target();
+            target.setAppId(appId);
+            target.setClientId(clientId);
+
+            try {
+
+                new Thread(new Runnable() {
+//                    IPushResult ret = null;
+                    @Override
+                    public void run() {
+//                        ret = push.pushMessageToSingle(iMessage, target);
+                         push.pushMessageToSingle(iMessage, target);
+//                        rets = ret;
+                    }
+
+
+                }).start();
+
+            } catch (RequestException e) {
+                e.printStackTrace();
+                push.pushMessageToSingle(iMessage, target, e.getRequestId());
+            }
+        }
+    }
+
+
+    /**
+     * 个推发送信息
+     *
+     * @param clientId    设备号数组
+     * @param information 信息
+     * @param json        业务id
+     */
+    public static void push(String clientId, String title, String information, String json) {
+//        String type = "1";
+//        if(StringUtils.isNotEmpty(title)){
+//            type = title;
+//        }
+////        List<Filter> filters = new ArrayList<>();
+////        filters.add(Filter.eq("gtClientId", clientId));
+////        List<Equipment> list = equipmentService.findList(null, filters, null);
+////        if(list.size()>0){
+////            for(Equipment equipment:list){
+////                String channel = equipment.getChannel();
+////                String equimentType = equipment.getEquimentType();
+////                String client = equipment.getClientId();
+////                String substring = client.substring(client.length() - 1);
+////                if(substring.equals("x")){
+////                    break;
+////                }
+////                if(StringUtils.isEmpty(channel)||channel.equals("1")||StringUtils.isEmpty(equimentType)){
+////                    //用个推
+////                    type = "1";
+////                }
+////                if(channel.equals("2")||StringUtils.isNotEmpty(equimentType)){
+////                    //用mq
+////                    type = "2";
+////                    //1 创建消息
+////                    MessageProperties messageProperties = new MessageProperties();
+////                    messageProperties.setContentType("text/plain");
+////                    //设置消息的过期时间,60秒
+//////        messageProperties.setExpiration("60000");
+////                    Message message = new Message(json.getBytes(), messageProperties);
+////
+////                    rabbitTemplate.send(equimentType, client, message);
+////                }
+////            }
+////        }
+//        if(type.equals("2")){
+//            String[] split = information.split(":");
+//            String equimentType = split[0];
+//            String client = split[1];
+//            //1 创建消息
+//            MessageProperties messageProperties = new MessageProperties();
+//            messageProperties.setContentType("text/plain");
+//            //设置消息的过期时间,60秒
+////        messageProperties.setExpiration("60000");
+//            Message message = new Message(json.getBytes(), messageProperties);
+//            rabbitTemplate.convertAndSend(equimentType, client, message);
+////            rabbitTemplate.send(equimentType, client, message);
+//        }
+//
+//        if(type.equals("1")){
+//            TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
+//            //推送ios
+//            final SingleMessage iMessage = new SingleMessage();
+//            iMessage.setOffline(true);
+//            // 离线有效时间,单位为毫秒,可选
+//            iMessage.setOfflineExpireTime(24 * 3600 * 1000);
+//            iMessage.setData(transmissionTemplate);
+//            // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
+//            iMessage.setPushNetWorkType(0);
+//
+//
+//            //个推
+//            final Target target = new Target();
+//            target.setAppId(appId);
+//            target.setClientId(clientId);
+//            try {
+//
+//                new Thread(new Runnable() {
+//
+//                    @Override
+//                    public void run() {
+//                        push.pushMessageToSingle(iMessage, target);
+//                    }
+//
+//
+//                }).start();
+//
+//            } catch (RequestException e) {
+//                e.printStackTrace();
+//                push.pushMessageToSingle(iMessage, target, e.getRequestId());
+//            }
+//        }
+        TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
+        //推送ios
+        final SingleMessage iMessage = new SingleMessage();
+        iMessage.setOffline(true);
+        // 离线有效时间,单位为毫秒,可选
+        iMessage.setOfflineExpireTime(24 * 3600 * 1000);
+        iMessage.setData(transmissionTemplate);
+        // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
+        iMessage.setPushNetWorkType(0);
+
+
+        //个推
+        final Target target = new Target();
+        target.setAppId(appId);
+        target.setClientId(clientId);
+        try {
+
+            new Thread(new Runnable() {
+
+                @Override
+                public void run() {
+                    push.pushMessageToSingle(iMessage, target);
+                }
+
+
+            }).start();
+
+        } catch (RequestException e) {
+            e.printStackTrace();
+            push.pushMessageToSingle(iMessage, target, e.getRequestId());
+        }
+    }
+
+    /**
+     * 苹果使用透传消息,通过设置payload信息,实现待机时的推送提醒;
+     * 对安卓来说就是没有payload的概念,所以需要去解析透传的消息,把title和body放在透传消息中
+     */
+    private static TransmissionTemplate getTemplate(String title, String msg, String json) {
+        title = title == null ? "" : title;
+        msg = msg == null ? "" : msg;
+        TransmissionTemplate template = new TransmissionTemplate();
+        template.setAppId(appId);
+        template.setAppkey(appKey);
+        template.setTransmissionContent(json);
+        template.setTransmissionType(2);
+        APNPayload payload = new APNPayload();
+        //在已有数字基础上加1显示,设置为-1时,在已有数字上减1显示,设置为数字时,显示指定数字
+        payload.setAutoBadge("+1");
+        payload.setContentAvailable(0);
+        payload.setSound("default");
+        payload.setCategory("$由客户端定义");
+        payload.addCustomMsg("payload",json);//好假
+
+        //字典模式使用APNPayload.DictionaryAlertMsg
+        //payload.setAlertMsg(getDictionaryAlertMsg(msg, title));
+
+        template.setAPNInfo(payload);
+        return template;
+    }
+
+    private static APNPayload.DictionaryAlertMsg getDictionaryAlertMsg(String msg, String title) {
+        APNPayload.DictionaryAlertMsg alertMsg = new APNPayload.DictionaryAlertMsg();
+        alertMsg.setBody(msg);//通知小内容
+        alertMsg.setActionLocKey("ActionLockey");
+        alertMsg.setLocKey("LocKey");
+        alertMsg.addLocArg("loc-args");
+        alertMsg.setLaunchImage("launch-image");
+
+        // iOS8.2以上版本支持
+        alertMsg.setTitle(title);//通知标题
+        alertMsg.setTitleLocKey("");
+        alertMsg.addTitleLocArg("");
+        return alertMsg;
+    }
+
+
+    public static JSONObject buildJson(String kind, String kindData) {
+        JSONObject jsonObject = new JSONObject();
+        if (kind != null) {
+            jsonObject.put("kind", kind);
+            jsonObject.put("kind_data", kindData);
+        }else{
+            jsonObject.put("kind", "");
+            jsonObject.put("kind_data", "");
+        }
+        return jsonObject;
+    }
+    public static JSONObject buildJson(String kind, String kindData,String netTime,String webTime) {
+        JSONObject jsonObject = new JSONObject();
+        if (kind != null) {
+            jsonObject.put("kind", kind);
+            jsonObject.put("kind_data", kindData);
+            jsonObject.put("netTime", netTime);
+            jsonObject.put("webTime", webTime);
+        }else{
+            jsonObject.put("kind", "");
+            jsonObject.put("kind_data", "");
+            jsonObject.put("netTime", "");
+            jsonObject.put("webTime", "");
+        }
+        return jsonObject;
+    }
+
+//    public static void main(String[] args) {
+//        push("71963777bd63e0f0a5b6490f04bf1ae4", "niai", "123", buildJson("editNo", "123456789").toString());
+//    }
+}

+ 11 - 0
src/test/java/com/szwl/ApplicationTests.java

@@ -0,0 +1,11 @@
+package com.szwl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@Slf4j
+@SpringBootTest
+class ApplicationTests {
+
+
+}

+ 74 - 0
src/test/java/com/szwl/AutoGeneratorTests.java

@@ -0,0 +1,74 @@
+package com.szwl;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
+import com.baomidou.mybatisplus.generator.config.GlobalConfig;
+import com.baomidou.mybatisplus.generator.config.PackageConfig;
+import com.baomidou.mybatisplus.generator.config.StrategyConfig;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@Slf4j
+@SpringBootTest
+class AutoGeneratorTests {
+	@Test
+	void contextLoads() {
+		AutoGenerator autoGenerator = new AutoGenerator();
+
+		//获取工程的根目录
+		String projectPath = System.getProperty("user.dir");//得到当前项目的路径
+		//全局配置
+		GlobalConfig globalConfig = new GlobalConfig();
+		globalConfig.setAuthor("wuhs")
+				.setOutputDir(projectPath + "/src/main/java")//设置输出路径,项目所在路径
+				.setFileOverride(true)//设置文件覆盖
+				.setOpen(false)//是否生成代码后打开本地目录
+				.setSwagger2(true) //实体属性 Swagger2 注解
+				.setIdType(IdType.ASSIGN_ID)//设置主键生成策略
+				.setServiceName("%sService")//service接口的名称
+				.setDateType(DateType.ONLY_DATE)
+				.setBaseResultMap(true)//基本结果集合
+				.setBaseColumnList(true)//设置基本的列
+				.setControllerName("%sController");
+
+		//配置数据源
+		//配置数据源
+		DataSourceConfig dataSourceConfig = new DataSourceConfig();
+		dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver")
+				.setUrl("jdbc:mysql://rm-wz995mu26a1479kz0so.mysql.rds.aliyuncs.com:3306/orderdb")
+				.setUsername("root").setPassword("sunzee@020");
+
+		//策略配置
+		StrategyConfig strategyConfig = new StrategyConfig();
+		strategyConfig
+//				.setCapitalMode(true)//设置全局大写命名
+				.setInclude(new String[]{
+						""
+				})//只会生成该表
+				.setEntityLombokModel(true)//实体类生成之后自动添加lombok注解
+				.setNaming(NamingStrategy.underline_to_camel)//数据库表映射到实体的命名策略
+				.setColumnNaming(NamingStrategy.underline_to_camel)//将数据库中带下划线的转成驼峰规则
+				//.setTablePrefix("tbl_")//设置表名前缀
+				.setRestControllerStyle(true)//controller是否使用restful风格
+		;
+
+		//包名配置
+		PackageConfig packageConfig = new PackageConfig();
+		packageConfig.setParent("com.szwl")
+				.setMapper("mapper")//包路径
+				.setService("service")
+				.setController("controller")
+				.setEntity("model.entity")
+//		.setXml()
+		;
+
+		autoGenerator.setGlobalConfig(globalConfig).setDataSource(dataSourceConfig)
+				.setStrategy(strategyConfig).setPackageInfo(packageConfig);
+
+		autoGenerator.execute();
+	}
+}