소스 검색

新增app-rest、provider模块

shanxin 4 년 전
부모
커밋
1b5cac5d26
24개의 변경된 파일1692개의 추가작업 그리고 21개의 파일을 삭제
  1. 1 0
      pom.xml
  2. 1 1
      sailun-allsteel-admin-rest/src/main/resources/application.yml
  3. 1 1
      sailun-allsteel-app-rest/src/main/resources/application.yml
  4. 21 0
      sailun-allsteel-bus-provider/pom.xml
  5. 41 0
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/pom.xml
  6. 159 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/pom.xml
  7. 22 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/BusinessServiceApplication.java
  8. 31 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/config/MybatisPlusConfig.java
  9. 57 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/config/RedisConfig.java
  10. 40 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/ElectricFenceUtil.java
  11. 672 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/FtpUtils.java
  12. 47 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/IdUtil.java
  13. 66 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/MultipartFileToFile.java
  14. 50 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/PageUtil.java
  15. 146 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/QRBarCodeUtil.java
  16. 92 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/RedisUtils.java
  17. 52 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/TimeUtil.java
  18. 89 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/application-dev.yml
  19. 1 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/application-test.yml
  20. 28 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/application.yml
  21. 5 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/banner.txt
  22. 58 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/logback-spring.xml
  23. 11 18
      sailun-allsteel-sys-provider/sailun-allsteel-sys-service/src/main/resources/application-dev.yml
  24. 1 1
      sailun-allsteel-sys-provider/sailun-allsteel-sys-service/src/main/resources/banner.txt

+ 1 - 0
pom.xml

@@ -8,6 +8,7 @@
         <module>sailun-allsteel-admin-rest</module>
         <module>sailun-allsteel-sys-provider</module>
         <module>sailun-allsteel-app-rest</module>
+        <module>sailun-allsteel-bus-provider</module>
     </modules>
 
     <parent>

+ 1 - 1
sailun-allsteel-admin-rest/src/main/resources/application.yml

@@ -26,7 +26,7 @@ spring:
 system:
      app:
         name: "sailun-steel"
-        desc: "赛轮全钢营销"
+        desc: "赛轮全钢-运营平台rest"
 
 platform:
     redis:

+ 1 - 1
sailun-allsteel-app-rest/src/main/resources/application.yml

@@ -26,7 +26,7 @@ spring:
 system:
      app:
         name: "sailun-allsteel"
-        desc: "赛轮全钢app"
+        desc: "赛轮全钢app rest"
 
 platform:
     redis:

+ 21 - 0
sailun-allsteel-bus-provider/pom.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>sailun-allsteel</artifactId>
+        <groupId>io.platform</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>sailun-allsteel-bus-provider</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <modules>
+        <module>saillun-allsteel-bus-api</module>
+        <module>sailun-allsteel-bus-service</module>
+    </modules>
+
+
+</project>

+ 41 - 0
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/pom.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>sailun-allsteel-bus-provider</artifactId>
+        <groupId>io.platform</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>io.platform.sailun.allsteel</groupId>
+    <artifactId>saillun-allsteel-bus-api</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.platform.sailun.allsteel</groupId>
+            <artifactId>sailun-allsteel-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

+ 159 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/pom.xml

@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>sailun-allsteel-bus-provider</artifactId>
+        <groupId>io.platform</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>io.platform.sailun.allsteel</groupId>
+    <artifactId>sailun-allsteel-bus-service</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <dependencies>
+        <dependency>
+            <groupId>io.platform.sailun.allsteel</groupId>
+            <artifactId>saillun-allsteel-bus-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>io.platform.sailun.allsteel</groupId>
+            <artifactId>sailun-allsteel-sys-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>io.platform.sailun.allsteel</groupId>
+            <artifactId>sailun-allsteel-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>io.platform.spring.boot</groupId>
+            <artifactId>dubbo-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.101tec</groupId>
+            <artifactId>zkclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+        </dependency>
+        <!-- mybatis-plus begin -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus</artifactId>
+        </dependency>
+        <!--<dependency>-->
+        <!--<groupId>mysql</groupId>-->
+        <!--<artifactId>mysql-connector-java</artifactId>-->
+        <!--</dependency>-->
+        <dependency>
+            <groupId>com.oracle</groupId>
+            <artifactId>ojdbc6</artifactId>
+            <version>11.2.0.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-test</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.jpush.api</groupId>
+            <artifactId>jpush-client</artifactId>
+            <version>3.3.10</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.jpush.api</groupId>
+            <artifactId>jiguang-common</artifactId>
+            <version>1.1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+            <version>4.1.6.Final</version>
+            <scope>compile</scope>
+        </dependency>
+        <!-- google二维码生成 -->
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>3.3.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>javase</artifactId>
+            <version>3.3.3</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 22 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/BusinessServiceApplication.java

@@ -0,0 +1,22 @@
+package io.platform;
+
+import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+@EnableDubboConfiguration
+@EnableScheduling
+public class BusinessServiceApplication extends SpringBootServletInitializer {
+
+    public static void main(String[] args) {
+        SpringApplication.run(BusinessServiceApplication.class, args);
+    }
+    @Override
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+        return application.sources(BusinessServiceApplication.class);
+    }
+}

+ 31 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/config/MybatisPlusConfig.java

@@ -0,0 +1,31 @@
+package io.platform.config;
+
+import com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator;
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * mybatis-plus配置
+ *
+ * @author Mark sunlightcs@gmail.com
+ * @since 2.0.0 2018-02-05
+ */
+@Configuration
+public class MybatisPlusConfig {
+
+    /**
+     * 分页插件
+     */
+    @Bean
+    public PaginationInterceptor paginationInterceptor() {
+        PaginationInterceptor page = new PaginationInterceptor();
+        page.setDialectType("oracle");
+        return page;
+    }
+
+    @Bean
+    public OracleKeyGenerator oracleKeyGenerator(){
+        return new OracleKeyGenerator();
+    }
+}

+ 57 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/config/RedisConfig.java

@@ -0,0 +1,57 @@
+package io.platform.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.*;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * Redis配置
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017-07-70 19:22
+ */
+@Configuration
+public class RedisConfig {
+    @Autowired
+    private RedisConnectionFactory factory;
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate() {
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashValueSerializer(new StringRedisSerializer());
+        redisTemplate.setValueSerializer(new StringRedisSerializer());
+        redisTemplate.setConnectionFactory(factory);
+        return redisTemplate;
+    }
+
+    @Bean
+    public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForHash();
+    }
+
+    @Bean
+    public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
+        return redisTemplate.opsForValue();
+    }
+
+    @Bean
+    public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForList();
+    }
+
+    @Bean
+    public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForSet();
+    }
+
+    @Bean
+    public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForZSet();
+    }
+}

+ 40 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/ElectricFenceUtil.java

@@ -0,0 +1,40 @@
+package io.platform.utils;
+
+/**
+ * @author sx
+ * @date 2020/09/04
+ */
+public class ElectricFenceUtil {
+    /**
+     * 地球半径,单位 km
+     */
+    private static final double EARTH_RADIUS = 6378.137;
+
+    /**
+     * 根据经纬度,计算两点间的距离
+     *
+     * @param longitude1 第一个点的经度
+     * @param latitude1  第一个点的纬度
+     * @param longitude2 第二个点的经度
+     * @param latitude2  第二个点的纬度
+     * @return 返回距离 单位千米
+     */
+    public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
+        // 纬度
+        double lat1 = Math.toRadians(latitude1);
+        double lat2 = Math.toRadians(latitude2);
+        // 经度
+        double lng1 = Math.toRadians(longitude1);
+        double lng2 = Math.toRadians(longitude2);
+        // 纬度之差
+        double a = lat1 - lat2;
+        // 经度之差
+        double b = lng1 - lng2;
+        // 计算两点距离的公式
+        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
+                Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
+        // 弧长乘地球半径, 返回单位: 米
+        s =  s * EARTH_RADIUS * 1000;
+        return s;
+    }
+}

+ 672 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/FtpUtils.java

@@ -0,0 +1,672 @@
+package io.platform.utils;
+
+
+import cn.hutool.core.img.ImgUtil;
+import cn.hutool.core.io.FileUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.ftp.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.awt.*;
+import java.io.*;
+import java.net.SocketException;
+import java.util.regex.Pattern;
+
+/**
+ * Created by chen on 2017/12/27.
+ */
+@Component
+public class FtpUtils {
+    @Value("${ftp.userName}")
+    private String userName;     //登录名
+    @Value("${ftp.password}")
+    private String password;     //密码
+    @Value("${ftp.ftpHostName}")
+    private String ftpHostName;  //ftp地址
+    @Value("${ftp.port}")
+    private int port;       //端口
+
+    @Value("${ftp.rootPath}")
+    private String rootPath;     // upload/admin/
+
+    @Value("${ftp.httpAddr}")
+    private String httpAddr;   // http://117.50.20.112/upload/
+
+    @Value("${ftp.tempDir}")
+    private String tempDir;
+
+    private FTPClient ftpClient = new FTPClient();
+    private OutputStream os = null;
+    private InputStream is = null;
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    private Pattern pattern = Pattern.compile("\\d{8}");    //8位数字
+
+
+    /**
+     * 建立链接
+     */
+    private void connect() {
+        try {
+            logger.info("开始链接..." + ftpHostName +"..."+ port);
+            ftpClient.connect(ftpHostName, port);
+            int reply = ftpClient.getReplyCode();   //ftp响应码
+            logger.error("ftp响应状态码"+reply);
+            if (!FTPReply.isPositiveCompletion(reply)) {  //ftp拒绝链接
+                logger.error("ftp拒绝链接...");
+                ftpClient.disconnect();
+            }
+            ftpClient.login(userName, password);
+            ftpClient.enterLocalPassiveMode();       //设置被动模式    通知server端开通端口传输数据
+            ftpClient.setBufferSize(256);
+            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+            ftpClient.setControlEncoding("utf-8");
+            logger.info("登录成功!");
+        } catch (SocketException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 退出FTP登录关闭链接   并  关闭输入输出流
+     *
+     * @param
+     */
+    private void close() {
+        try {
+            if (is != null) {
+                is.close();
+            }
+            if (os != null) {
+                os.flush();
+                os.close();
+            }
+            ftpClient.logout();
+            logger.info("退出登录!");
+            ftpClient.disconnect();
+            logger.info("关闭链接!");
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+
+    /**
+     * 判断是否是目录
+     *
+     * @param fileName
+     * @return
+     */
+    public boolean isDir(String fileName) {
+        try {
+            // 切换目录,若当前是目录则返回true,否则返回true。
+            boolean falg = ftpClient.changeWorkingDirectory(fileName);
+            return falg;
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+        }
+        return false;
+    }
+
+
+    /**
+     * 上传文件
+     *
+     * @param exPath  自定义目录,默认空
+     * @param extName 文件后缀名
+     * @param in      文件输入流
+     */
+    public String defaultUpload(String exPath, String extName, FileInputStream in) {
+        connect();
+        String ftpPath;
+
+        if (StringUtils.isNotEmpty(exPath)) {
+            ftpPath = rootPath + exPath;
+        } else {
+            ftpPath = rootPath;
+        }
+
+        String fileName = IdUtil.createIdByTime() + "." + extName;
+
+        boolean flag = uploadFileByDo(ftpPath, fileName, in);
+        close();
+        String url = null;
+        if (flag) {
+            url = httpAddr + ftpPath + "/" + fileName;
+        }
+        return url;
+    }
+
+    /**
+     * 上传文件
+     *
+     * @param ftpPath
+     * @param fileName
+     */
+    public boolean uploadFile(String ftpPath, String fileName, InputStream is) {
+        connect();
+        boolean flag = uploadFileByDo(ftpPath, fileName, is);
+        close();
+        return flag;
+    }
+
+    /**
+     * 下载文件
+     *
+     * @param remoteFtpPath
+     * @param localPath
+     * @param fileName
+     * @return
+     */
+    public boolean downloadFile(String remoteFtpPath, String localPath, String fileName) {
+        connect();
+        boolean flag = this.downloadFileByDo(remoteFtpPath, localPath, fileName);
+        close();
+        return flag;
+    }
+
+    /**
+     * 删除ftp上的文件
+     *
+     * @param ftpFileName
+     * @return true || false
+     */
+    public boolean removeFile(String ftpFileName) {
+        boolean flag = false;
+        logger.info("待删除文件:{0}"
+                , ftpFileName);
+        try {
+            ftpFileName = new String(ftpFileName.getBytes("GBK"), "iso-8859-1");
+            flag = ftpClient.deleteFile(ftpFileName);
+            logger.info("删除文件:[{0}]"
+                    , flag ? "成功" : "失败");
+            return flag;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 删除空目录
+     *
+     * @param dir
+     * @return
+     */
+    public boolean removeDir(String dir) {
+        if (StringUtils.startsWith(dir, "/"))
+            dir = "/" + dir;
+        try {
+            String d = new String(dir.toString().getBytes("GBK"), "iso-8859-1");
+            return ftpClient.removeDirectory(d);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 创建目录(有则切换目录,没有则创建目录)
+     *
+     * @param dir
+     * @return
+     */
+    public boolean createDir(String dir) {
+        if (StringUtils.isBlank(dir))
+            return true;
+        String d;
+        try {
+            //目录编码,解决中文路径问题
+            d = new String(dir.toString().getBytes("GBK"), "iso-8859-1");
+            //尝试切入目录
+            if (ftpClient.changeWorkingDirectory(d))
+                return true;
+            String[] arr = dir.split("/");
+            StringBuffer sbfDir = new StringBuffer();
+            //循环生成子目录
+            for (String s : arr) {
+                sbfDir.append("/");
+                sbfDir.append(s);
+                //目录编码,解决中文路径问题
+                d = new String(sbfDir.toString().getBytes("GBK"), "iso-8859-1");
+                //尝试切入目录
+                if (ftpClient.changeWorkingDirectory(d))
+                    continue;
+                if (!ftpClient.makeDirectory(d)) {
+                    logger.info("[失败]ftp创建目录:" + sbfDir.toString());
+                    return false;
+                }
+                logger.info("[成功]创建ftp目录:" + sbfDir.toString());
+            }
+            //将目录切换至指定路径
+            return ftpClient.changeWorkingDirectory(d);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 上传文件
+     *
+     * @param ftpPath  FTP服务器保存目录
+     * @param fileName 上传到FTP服务器上的文件名
+     */
+    private boolean uploadFileByDo(String ftpPath, String fileName, InputStream is) {
+        try {
+            if (!createDir(ftpPath)) {
+                throw new RuntimeException("切入FTP目录失败:" + ftpPath);
+            }
+            ftpClient.setBufferSize(1024);
+            //解决上传中文 txt 文件乱码
+            ftpClient.setControlEncoding("utf-8");
+            FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_NT);
+            conf.setServerLanguageCode("zh");
+            // 设置文件类型(二进制)
+            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+            if (ftpClient.storeFile(fileName, is)) {
+                is.close();
+                return true;
+            } else {
+                logger.info("上传文件失败!");
+                return false;
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+            return false;
+        } finally {
+            try {
+                if (is != null) {
+                    is.close();
+                }
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                logger.error(e.getMessage(), e);
+            }
+        }
+    }
+
+    /**
+     * 下载文件
+     *
+     * @param remoteFtpPath FTP服务器保存目录
+     *                      localPath
+     * @param fileName      上传到FTP服务器上的文件名
+     */
+    private boolean downloadFileByDo(String remoteFtpPath, String localPath, String fileName) {
+        try {
+            boolean changedir = ftpClient.changeWorkingDirectory(remoteFtpPath);
+            if (!changedir) {
+                logger.info("切入目录失败!");
+                return false;
+            }
+            ftpClient.setBufferSize(1024);
+            //解决上传中文 txt 文件乱码
+            ftpClient.setControlEncoding("utf-8");
+            FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_NT);
+            conf.setServerLanguageCode("zh");
+            // 设置文件类型(二进制)
+            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+            FTPFile[] files = ftpClient.listFiles();
+            for (int i = 0; i < files.length; i++) {
+                try {
+                    if (fileName.equals(files[i].getName())) {
+                        downloadFile(files[i], localPath, remoteFtpPath);
+                        return true;
+                    }
+                } catch (Exception e) {
+                    logger.error("下载异常", e);
+                    logger.error("<" + files[i].getName() + ">下载失败");
+                }
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+            return false;
+        } finally {
+            try {
+                if (is != null) {
+                    is.close();
+                }
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                logger.error(e.getMessage(), e);
+            }
+
+        }
+        return true;
+    }
+
+    /**
+     * 下载FTP文件
+     * 当你需要下载FTP文件的时候,调用此方法
+     * 根据<b>获取的文件名,本地地址,远程地址</b>进行下载
+     *
+     * @param ftpFile
+     * @param relativeLocalPath
+     * @param relativeRemotePath
+     */
+    private void downloadFile(FTPFile ftpFile, String relativeLocalPath, String relativeRemotePath) {
+        if (ftpFile.isFile()) {
+            if (ftpFile.getName().indexOf("?") == -1) {
+                OutputStream outputStream = null;
+                try {
+                    File entryDir = new File(relativeLocalPath);
+                    //如果文件夹路径不存在,则创建文件夹
+                    if (!entryDir.exists() || !entryDir.isDirectory()) {
+                        entryDir.mkdirs();
+                    }
+                    File locaFile = new File(relativeLocalPath + ftpFile.getName());
+                    //判断文件是否存在,存在则返回
+                    if (locaFile.exists()) {
+                        return;
+                    } else {
+                        outputStream = new FileOutputStream(relativeLocalPath + ftpFile.getName());
+                        ftpClient.retrieveFile(ftpFile.getName(), outputStream);
+                        outputStream.flush();
+                        outputStream.close();
+                    }
+                } catch (Exception e) {
+                    logger.error("下载异常", e);
+                } finally {
+                    try {
+                        if (outputStream != null) {
+                            outputStream.close();
+                        }
+                    } catch (IOException e) {
+                        logger.error("输出文件流异常");
+                    }
+                }
+            }
+        } else {
+            String newlocalRelatePath = relativeLocalPath + ftpFile.getName();
+            String newRemote = new String(relativeRemotePath + ftpFile.getName().toString());
+            File fl = new File(newlocalRelatePath);
+            if (!fl.exists()) {
+                fl.mkdirs();
+            }
+            try {
+                newlocalRelatePath = newlocalRelatePath + '/';
+                newRemote = newRemote + "/";
+                String currentWorkDir = ftpFile.getName().toString();
+                boolean changedir = ftpClient.changeWorkingDirectory(currentWorkDir);
+                if (changedir) {
+                    FTPFile[] files = null;
+                    files = ftpClient.listFiles();
+                    for (int i = 0; i < files.length; i++) {
+                        downloadFile(files[i], newlocalRelatePath, newRemote);
+                    }
+                }
+                if (changedir) {
+                    ftpClient.changeToParentDirectory();
+                }
+            } catch (Exception e) {
+                logger.error("下载异常", e);
+            }
+        }
+    }
+
+    /**
+     * 下载文件
+     *
+     * @param remoteFtpPath FTP服务器保存目录
+     *                      localPath
+     * @param fileName      上传到FTP服务器上的文件名
+     */
+    public File getFtpFile(String remoteFtpPath, String fileName) {
+        connect();
+        File file = null;
+        try {
+            boolean changedir = ftpClient.changeWorkingDirectory(remoteFtpPath);
+            if (!changedir) {
+                logger.info("切入目录失败!");
+                return file;
+            }
+            ftpClient.setBufferSize(1024);
+            //解决上传中文 txt 文件乱码
+            ftpClient.setControlEncoding("utf-8");
+            FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_NT);
+            conf.setServerLanguageCode("zh");
+            // 设置文件类型(二进制)
+            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+            FTPFile[] files = ftpClient.listFiles();
+            for (int i = 0; i < files.length; i++) {
+                try {
+                    if (fileName.equals(files[i].getName())) {
+                        InputStream fis = ftpClient.retrieveFileStream(files[i].getName());
+                        file = new File("drtext.xlsx");
+                        OutputStream os = new FileOutputStream(file);
+                        int bytesRead = 0;
+                        byte[] buffer = new byte[1024];
+                        while ((bytesRead = fis.read(buffer, 0, 1024)) != -1) {
+                            os.write(buffer, 0, bytesRead);
+                        }
+                        os.close();
+                        fis.close();
+                        return file;
+                    }
+                } catch (Exception e) {
+                    logger.error("读取异常", e);
+                }
+            }
+            close();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            logger.error(e.getMessage(), e);
+        } finally {
+            try {
+                if (is != null) {
+                    is.close();
+                }
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                logger.error(e.getMessage(), e);
+            }
+
+        }
+        return file;
+    }
+
+
+    public String getUserName() {
+        return userName;
+    }
+
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+
+    public String getPassword() {
+        return password;
+    }
+
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+
+    public String getFtpHostName() {
+        return ftpHostName;
+    }
+
+
+    public void setFtpHostName(String ftpHostName) {
+        this.ftpHostName = ftpHostName;
+    }
+
+
+    public int getPort() {
+        return port;
+    }
+
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public OutputStream getOs() {
+        return os;
+    }
+
+    public void setOs(OutputStream os) {
+        this.os = os;
+    }
+
+    /*public String uploadImage(String extPath, String extName, FileInputStream ins) {
+        connect();
+        String ftpPath;
+        if (StringUtils.isNotEmpty(extPath)) {
+            ftpPath = rootPath + extPath;
+        } else {
+            ftpPath = rootPath;
+        }
+
+        String fileName = IdUtil.createIdByTime() + "." + extName;
+        boolean flag = uploadFileByDo(ftpPath, fileName, ins);
+            close();
+            String url = null;
+            if (flag) {
+                url = httpAddr + ftpPath + fileName;
+                //FileUtil.del(tempFile);
+            }
+            return url;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }*/
+
+
+    /**
+     * 测试文件上传
+     * 1.原目标文件流
+     * 2.目标文件流
+     */
+    public String uploadImage(String extPath, String extName, File file) throws FileNotFoundException {
+        connect();
+        String ftpPath;
+        if (StringUtils.isNotEmpty(extPath)) {
+            ftpPath = rootPath + extPath;
+        } else {
+            ftpPath = rootPath;
+        }
+        System.out.println(file.length());
+        FileInputStream ins = new FileInputStream(file);
+        String fileName = IdUtil.createIdByTime() + "." + extName;
+        File tempFile = FileUtil.writeFromStream(ins, tempDir + "/" + fileName);
+        BufferedOutputStream  out = FileUtil.getOutputStream(tempFile);
+
+        try {
+            //TODO 打水印
+            ImgUtil.pressText(
+                    file, //
+                    tempFile,
+                    "赛轮版权所有", Color.WHITE, //文字
+                    new Font("黑体", Font.BOLD, 50), //字体
+                    0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
+                    0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
+                    0.5f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
+            );
+            //System.out.println(tempFile.length());
+            boolean flag = uploadFileByDo(ftpPath, fileName, new FileInputStream(tempFile));
+            close();
+            String url = null;
+            if (flag) {
+                url = httpAddr + ftpPath + fileName;
+                FileUtil.del(tempFile);
+                //this.deleteAllFilesOfDir(tempFile);
+            }
+            return url;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public String uploadImageForStram(String extPath, String extName, InputStream inputStream) throws FileNotFoundException {
+        connect();
+        String ftpPath;
+        if (StringUtils.isNotEmpty(extPath)) {
+            ftpPath = rootPath + extPath;
+        } else {
+            ftpPath = rootPath;
+        }
+        String fileName = IdUtil.createIdByTime() + "." + extName;
+        File tempFile = FileUtil.writeFromStream(inputStream, tempDir + "/" + fileName);
+        BufferedOutputStream  out = FileUtil.getOutputStream(tempFile);
+
+        try {
+            //TODO 打水印
+            ImgUtil.pressText(
+                    inputStream, //
+                    out,
+                    "赛轮版权所有", Color.WHITE, //文字
+                    new Font("黑体", Font.BOLD, 50), //字体
+                    0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
+                    0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
+                    0.5f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
+            );
+            //System.out.println(tempFile.length());
+            boolean flag = uploadFileByDo(ftpPath, fileName, new FileInputStream(tempFile));
+            close();
+            String url = null;
+            if (flag) {
+                url = httpAddr + ftpPath + fileName;
+                FileUtil.del(tempFile);
+                //FileUtil.del(tempFile);
+                //this.deleteAllFilesOfDir(tempFile);
+            }
+            return url;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+
+
+
+    public static void deleteAllFilesOfDir(File path) {
+        if (null != path) {
+            if (!path.exists())
+                return;
+            if (path.isFile()) {
+                boolean result = path.delete();
+                int tryCount = 0;
+                while (!result && tryCount++ < 10) {
+                    System.gc(); // 回收资源
+                    result = path.delete();
+                }
+            }
+            File[] files = path.listFiles();
+            if (null != files) {
+                for (int i = 0; i < files.length; i++) {
+                    deleteAllFilesOfDir(files[i]);
+                }
+            }
+            path.delete();
+        }
+    }
+
+
+
+
+
+
+
+
+}

+ 47 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/IdUtil.java

@@ -0,0 +1,47 @@
+package io.platform.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * 名称:IdUtil <br>
+ * 描述:ID 生成工具类<br>
+ *
+ * @author 李鹏军
+ * @version 1.0
+ * @since 1.0.0
+ */
+public class IdUtil {
+    /**
+     * 主要功能:生成流水号 yyyyMMddHHmmssSSS + 3位随机数
+     * 注意事项:无
+     *
+     * @return 流水号
+     */
+    public static String createIdByDate() {
+        // 精确到毫秒
+        SimpleDateFormat fmt = new SimpleDateFormat("(yyyyMMddHHmmssSSS)");
+        String suffix = fmt.format(new Date());
+        suffix = suffix + "-" + Math.round((Math.random() * 100000));
+        return suffix;
+    }
+
+    /**
+     * 主要功能:生成uuid
+     * 注意事项:无
+     *
+     * @return uuid 32 位
+     */
+    public static String createIdbyUUID() {
+        return UUID.randomUUID().toString().replaceAll("-", "");
+    }
+
+    public static String createIdByTime() {
+        // 精确到毫秒
+        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+        String suffix = fmt.format(new Date());
+        suffix = suffix + Math.round((Math.random() * 100000));
+        return suffix;
+    }
+}

+ 66 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/MultipartFileToFile.java

@@ -0,0 +1,66 @@
+package io.platform.utils;
+
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @ClassName MultipartFileToFile
+ * @Description MultipartFile转fie
+ * @Author TongGuoBo
+ * @Date 2019/6/19 13:48
+ **/
+public class MultipartFileToFile {
+
+    /**
+     * MultipartFile 转 File
+     *
+     * @param file
+     * @throws Exception
+     */
+    public static File multipartFileToFile(MultipartFile file) throws Exception {
+
+        File toFile = null;
+        if (file.equals("") || file.getSize() <= 0) {
+            file = null;
+        } else {
+            InputStream ins = null;
+            ins = file.getInputStream();
+            toFile = new File(file.getOriginalFilename());
+            inputStreamToFile(ins, toFile);
+            ins.close();
+        }
+        return toFile;
+    }
+
+    //获取流文件
+    private static void inputStreamToFile(InputStream ins, File file) {
+        try {
+            OutputStream os = new FileOutputStream(file);
+            int bytesRead = 0;
+            byte[] buffer = new byte[8192];
+            while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            ins.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 删除本地临时文件
+     * @param file
+     */
+    public static void delteTempFile(File file) {
+        if (file != null) {
+            File del = new File(file.toURI());
+            del.delete();
+        }
+    }
+}

+ 50 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/PageUtil.java

@@ -0,0 +1,50 @@
+package io.platform.utils;
+
+import java.util.List;
+
+/**
+ * 自定义List分页工具
+ * @author hanwl
+ */
+public class PageUtil {
+
+    /**
+     * 开始分页
+     * @param list
+     * @param pageNum 页码
+     * @param pageSize 每页多少条数据
+     * @return
+     */
+    public static List startPage(List list, Integer pageNum,
+                                 Integer pageSize) {
+        if (list == null) {
+            return null;
+        }
+        if (list.size() == 0) {
+            return null;
+        }
+
+        Integer count = list.size(); // 记录总数
+        Integer pageCount = 0; // 页数
+        if (count % pageSize == 0) {
+            pageCount = count / pageSize;
+        } else {
+            pageCount = count / pageSize + 1;
+        }
+
+        int fromIndex = 0; // 开始索引
+        int toIndex = 0; // 结束索引
+
+        if (pageNum != pageCount) {
+            fromIndex = (pageNum - 1) * pageSize;
+            toIndex = fromIndex + pageSize;
+        } else {
+            fromIndex = (pageNum - 1) * pageSize;
+            toIndex = count;
+        }
+
+        List pageList = list.subList(fromIndex, toIndex);
+
+        return pageList;
+    }
+}

+ 146 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/QRBarCodeUtil.java

@@ -0,0 +1,146 @@
+package io.platform.utils;
+
+import cn.hutool.core.io.FileUtil;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.imageio.ImageIO;
+import javax.swing.filechooser.FileSystemView;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+/**
+ * Created by Administrator on 2018/11/8 0008.
+ * 二维码、条形码工具类
+ */
+@Component
+public class QRBarCodeUtil {
+
+    @Autowired
+    private FtpUtils ftpUtils;
+
+    @Value("${ftp.tempDir}")
+    private String tempDir;
+
+
+    /**
+     * CODE_WIDTH:二维码宽度,单位像素
+     * CODE_HEIGHT:二维码高度,单位像素
+     * FRONT_COLOR:二维码前景色,0x000000 表示黑色
+     * BACKGROUND_COLOR:二维码背景色,0xFFFFFF 表示白色
+     * 演示用 16 进制表示,和前端页面 CSS 的取色是一样的,注意前后景颜色应该对比明显,如常见的黑白
+     */
+    private static final int CODE_WIDTH = 400;
+    private static final int CODE_HEIGHT = 400;
+    private static final int FRONT_COLOR = 0x000000;
+    private static final int BACKGROUND_COLOR = 0xFFFFFF;
+
+    /**
+     * 生成二维码 并 保存为图片
+     */
+    /**
+     * @param codeContent        :二维码参数内容,如果是一个网页地址,如 https://www.baidu.com/ 则 微信扫一扫会直接进入此地址
+     *                           如果是一些参数,如 1541656080837,则微信扫一扫会直接回显这些参数值
+     */
+    public  String createCodeToFile(String codeContent) {
+        try {
+            /** 参数检验*/
+            if (codeContent == null || "".equals(codeContent)) {
+                // System.out.println("二维码内容为空,不进行操作...");
+                return null;
+            }
+            codeContent = codeContent.trim();
+            File codeImgFileSaveDir = new File(tempDir);
+            // System.out.println("二维码图片存在目录为空,默认放在桌面codeImgFileSaveDir");
+
+            if (!codeImgFileSaveDir.exists()) {
+                codeImgFileSaveDir.mkdirs();
+                // System.out.println("二维码图片存在目录不存在,开始创建...");
+            }
+            String fileName = new Date().getTime() + ".png";
+            // System.out.println("二维码图片文件名为空,随机生成 png 格式图片...");
+            /**com.google.zxing.EncodeHintType:编码提示类型,枚举类型
+             * EncodeHintType.CHARACTER_SET:设置字符编码类型
+             * EncodeHintType.ERROR_CORRECTION:设置误差校正
+             *      ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction
+             *      不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的
+             * EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近
+             * */
+            Map<EncodeHintType, Object> hints = new HashMap();
+            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
+            hints.put(EncodeHintType.MARGIN, 1);
+
+            /**
+             * MultiFormatWriter:多格式写入,这是一个工厂类,里面重载了两个 encode 方法,用于写入条形码或二维码
+             *      encode(String contents,BarcodeFormat format,int width, int height,Map<EncodeHintType,?> hints)
+             *      contents:条形码/二维码内容
+             *      format:编码类型,如 条形码,二维码 等
+             *      width:码的宽度
+             *      height:码的高度
+             *      hints:码内容的编码类型
+             * BarcodeFormat:枚举该程序包已知的条形码格式,即创建何种码,如 1 维的条形码,2 维的二维码 等
+             * BitMatrix:位(比特)矩阵或叫2D矩阵,也就是需要的二维码
+             */
+            MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
+            BitMatrix bitMatrix = multiFormatWriter.encode(codeContent, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT, hints);
+
+            /**java.awt.image.BufferedImage:具有图像数据的可访问缓冲图像,实现了 RenderedImage 接口
+             * BitMatrix 的 get(int x, int y) 获取比特矩阵内容,指定位置有值,则返回true,将其设置为前景色,否则设置为背景色
+             * BufferedImage 的 setRGB(int x, int y, int rgb) 方法设置图像像素
+             *      x:像素位置的横坐标,即列
+             *      y:像素位置的纵坐标,即行
+             *      rgb:像素的值,采用 16 进制,如 0xFFFFFF 白色
+             */
+            BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_BGR);
+            for (int x = 0; x < CODE_WIDTH; x++) {
+                for (int y = 0; y < CODE_HEIGHT; y++) {
+                    bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR);
+                }
+            }
+
+            /**javax.imageio.ImageIO java 扩展的图像IO
+             * write(RenderedImage im,String formatName,File output)
+             *      im:待写入的图像
+             *      formatName:图像写入的格式
+             *      output:写入的图像文件,文件不存在时会自动创建
+             *
+             * 即将保存的二维码图片文件*/
+            //上传文件
+            File codeImgFile = new File(codeImgFileSaveDir, fileName);
+            ImageIO.write(bufferedImage, "png", codeImgFile);
+            //上传文件
+            String codeImg = ftpUtils.defaultUpload("codeImg", FileUtil.extName(codeImgFile), new FileInputStream(codeImgFile));
+            System.out.println("二维码图片生成成功:" + codeImg);
+            //删除本地缓存文件
+            boolean b = codeImgFile.delete();
+            System.out.println(b);
+            return codeImg;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+    public InputStream bufferedImageToInputStream(BufferedImage image){
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        try {
+            ImageIO.write(image, "png", os);
+            InputStream input = new ByteArrayInputStream(os.toByteArray());
+            return input;
+        } catch (IOException e) {
+        }
+        return null;
+    }
+
+
+}

+ 92 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/RedisUtils.java

@@ -0,0 +1,92 @@
+package io.platform.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.*;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Redis工具类
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017-07-17 21:12
+ */
+@Component
+public class RedisUtils {
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+    @Autowired
+    private ValueOperations<String, String> valueOperations;
+    @Autowired
+    private HashOperations<String, String, Object> hashOperations;
+    @Autowired
+    private ListOperations<String, Object> listOperations;
+    @Autowired
+    private SetOperations<String, Object> setOperations;
+    @Autowired
+    private ZSetOperations<String, Object> zSetOperations;
+    /**  默认过期时长,单位:秒 */
+    public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
+    /**  不设置过期时长 */
+    public final static long NOT_EXPIRE = -1;
+
+    public void set(String key, Object value, long expire){
+        valueOperations.set(key, toJson(value));
+        if(expire != NOT_EXPIRE){
+            redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+        }
+    }
+
+    public void set(String key, Object value){
+        set(key, value, DEFAULT_EXPIRE);
+    }
+
+    public <T> T get(String key, Class<T> clazz, long expire) {
+        String value = valueOperations.get(key);
+        if(expire != NOT_EXPIRE){
+            redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+        }
+        return value == null ? null : fromJson(value, clazz);
+    }
+
+    public <T> T get(String key, Class<T> clazz) {
+        return get(key, clazz, NOT_EXPIRE);
+    }
+
+    public String get(String key, long expire) {
+        String value = valueOperations.get(key);
+        if(expire != NOT_EXPIRE){
+            redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+        }
+        return value;
+    }
+
+    public String get(String key) {
+        return get(key, NOT_EXPIRE);
+    }
+
+    public void delete(String key) {
+        redisTemplate.delete(key);
+    }
+
+    /**
+     * Object转成JSON数据
+     */
+    private String toJson(Object object){
+        if(object instanceof Integer || object instanceof Long || object instanceof Float ||
+                object instanceof Double || object instanceof Boolean || object instanceof String){
+            return String.valueOf(object);
+        }
+        return JSONObject.toJSONString(object);
+    }
+
+    /**
+     * JSON数据,转成Object
+     */
+    private <T> T fromJson(String json, Class<T> clazz){
+        return JSONObject.parseObject(json, clazz);
+    }
+}

+ 52 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/utils/TimeUtil.java

@@ -0,0 +1,52 @@
+package io.platform.utils;
+
+import org.apache.http.ParseException;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @author lgl
+ * @date 2020/05/08 16:28:40
+ */
+public class TimeUtil {
+    /**
+     * 判断当前时间是否在[startTime, endTime]区间,注意时间格式要一致
+     *
+     * @param nowTime 当前时间
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @return
+     * @author lgl
+     */
+    public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
+        if (nowTime.getTime() == startTime.getTime()
+                || nowTime.getTime() == endTime.getTime()) {
+            return true;
+        }
+
+        Calendar date = Calendar.getInstance();
+        date.setTime(nowTime);
+
+        Calendar begin = Calendar.getInstance();
+        begin.setTime(startTime);
+
+        Calendar end = Calendar.getInstance();
+        end.setTime(endTime);
+
+        if (date.after(begin) && date.before(end)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static void main(String[] args) throws ParseException, java.text.ParseException {
+        String format = "HH:mm:ss";
+        Date nowTime = new SimpleDateFormat(format).parse("10:27:00");
+        Date startTime = new SimpleDateFormat(format).parse("09:27:00");
+        Date endTime = new SimpleDateFormat(format).parse("09:27:59");
+        System.out.println(isEffectiveDate(nowTime, startTime, endTime));
+    }
+}

+ 89 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/application-dev.yml

@@ -0,0 +1,89 @@
+# 本地开发 环境配置
+spring:
+  dubbo:
+    server: true
+    registry: zookeeper://127.0.0.1:2181
+    protocol:
+      port: -1
+    application:
+      qosEnable: false
+      version: 1.0.0
+    provider:
+      timeout: 60000
+      retries: 0
+
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: oracle.jdbc.OracleDriver
+    url: jdbc:oracle:thin:@192.168.209.168:1521/crm
+    username: DEV_TBRMARKET_APP
+    password: market_app
+
+    hikari:
+      minimum-idle: 2
+      connection-timeout: 2000
+      maximum-pool-size: 20
+
+  redis: # redis配置
+    host: 10.97.1.104
+    password: "redis@sailun"
+    port: 6379
+    connection-time-out: 20000
+    database: 15
+
+    jedis:
+      pool:
+        max-idle: 8
+        min-idle: 0
+#mybatis
+mybatis-plus:
+  mapper-locations: classpath:/mybatis/**/*.xml
+  #实体扫描,多个package用逗号或者分号分隔
+  typeAliasesPackage: io.platform.*.biz.entity
+
+  global-config:
+    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
+    id-type: 1
+    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
+    field-strategy: 2
+    #驼峰下划线转换
+    db-column-underline: true
+    #刷新mapper 调试神器
+    refresh-mapper: true
+    #数据库大写下划线转换
+    capital-mode: true
+    #序列接口实现类配置
+    key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
+    #逻辑删除配置
+    #logic-delete-value: 0
+    #logic-not-delete-value: 1
+    #自定义填充策略接口实现
+    #meta-object-handler: com.baomidou.springboot.xxx
+    #自定义SQL注入器
+    #sql-injector: com.king.security.mybatis.interceptor.DataSecurityInterceptor
+  configuration:
+    map-underscore-to-camel-case: true
+    cache-enabled: false
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#logging
+logging:
+  org.springframework.web: info
+  org.springboot : info
+  io.platform : debug
+  com.alibaba : info
+  com.baomidou: info
+log:
+  path: log/
+  level: debug
+
+flagScope: true # 电子围栏开关
+
+ftp:
+  userName: sailun_dev
+  password: sailun_dev@sailun
+  ftpHostName: 10.97.1.106
+  port: 21
+  dataIp: http://10.97.1.106/
+  rootPath: /sailun-allsteel-app/  #必须有"/"
+  httpAddr: https://b2bcnfile.sailuntire.com/upload/
+  tempDir: /application/temp

+ 1 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/application-test.yml

@@ -0,0 +1 @@
+# 测试环境配置信息

+ 28 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/application.yml

@@ -0,0 +1,28 @@
+# Tomcat
+server:
+    tomcat:
+        uri-encoding: UTF-8
+        max-threads: 1000
+        min-spare-threads: 30
+    port: 9005
+#    context-path: /admin
+
+spring:
+    dubbo:
+        application:
+            name: sailun-biz-provider
+
+    # 环境 dev|test|pro
+    profiles:
+        active: dev
+
+    # jackson时间格式化
+    jackson:
+        time-zone: GMT+8
+        date-format: yyyy-MM-dd HH:mm:ss
+    http:
+        multipart:
+        max-file-size: 100MB
+        max-request-size: 100MB
+        enabled: true
+

+ 5 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/banner.txt

@@ -0,0 +1,5 @@
+====================================================================================================================
+
+             赛轮全钢系统业务模块 BUS DUBBO - ------------------正在启动
+
+====================================================================================================================

+ 58 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/logback-spring.xml

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <include resource="org/springframework/boot/logging/logback/base.xml" />
+    <logger name="org.springframework" level="ERROR"/>
+    <logger name="org.springboot" level="ERROR" />
+
+    <!-- 开发、测试环境 -->
+    <springProfile name="dev,test">
+        <logger name="org.springframework" level="ERROR"/>
+        <logger name="org.springboot" level="ERROR" />
+        <logger name="io.platform" level="DEBUG" />
+    </springProfile>
+
+    <!-- 生产环境 -->
+    <springProfile name="pro">
+        <logger name="org.springframework.web" level="ERROR"/>
+        <logger name="org.springboot.sample" level="ERROR" />
+        <logger name="io.platform" level="ERROR" />
+    </springProfile>
+    <contextName>web-rest</contextName>
+    <property name="logback.logdir" value="./log/"/>
+    <property name="logback.appname" value="biz-service"/>
+
+    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!--如果只是想要 Info 级别的日志,只是过滤 info 还是会输出 Error 日志,因为 Error 的级别高,
+        所以我们使用下面的策略,可以避免输出 Error 的日志-->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!--过滤 Error-->
+            <level>ERROR</level>
+            <!--匹配到就禁止-->
+            <onMatch>DENY</onMatch>
+            <!--没有匹配到就允许-->
+            <onMismatch>ACCEPT</onMismatch>
+        </filter>
+        <!--日志名称,如果没有File 属性,那么只会使用FileNamePattern的文件路径规则
+            如果同时有<File>和<FileNamePattern>,那么当天日志是<File>,明天会自动把今天
+            的日志改名为今天的日期。即,<File> 的日志都是当天的。
+        -->
+        <File>${logback.logdir}${logback.appname}.log</File>
+        <!--滚动策略,按照时间滚动 TimeBasedRollingPolicy-->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--文件路径,定义了日志的切分方式——把每一天的日志归档到一个文件中,以防止日志填满整个磁盘空间-->
+            <FileNamePattern>${logback.logdir}${logback.appname}.%d{yyyy-MM-dd}.log</FileNamePattern>
+            <!--只保留最近90天的日志-->
+            <maxHistory>90</maxHistory>
+            <!--用来指定日志文件的上限大小,那么到了这个值,就会删除旧的日志-->
+            <totalSizeCap>1GB</totalSizeCap>
+        </rollingPolicy>
+        <!--日志输出编码格式化-->
+        <encoder>
+            <charset>UTF-8</charset>
+            <pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="info">
+        <appender-ref ref="fileInfoLog" />
+    </root>
+</configuration>

+ 11 - 18
sailun-allsteel-sys-provider/sailun-allsteel-sys-service/src/main/resources/application-dev.yml

@@ -12,10 +12,8 @@ spring:
       timeout: 30000
 
   datasource:
-#    type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: oracle.jdbc.OracleDriver
     url: jdbc:oracle:thin:@192.168.209.168:1521/crm
-    #username: DEV_MARKETING_APP
     username: DEV_TBRMARKET_APP
     password: market_app
     hikari:
@@ -24,9 +22,9 @@ spring:
       maximum-pool-size: 20
 
   redis: # redis配置
-    host: 140.143.188.175
-    password: "redis@qqyun"
-    port: 6479
+    host: 10.97.1.104
+    password: "redis@sailun"
+    port: 6379
     connection-time-out: 20000
     database: 15
 
@@ -52,13 +50,6 @@ mybatis-plus:
     capital-mode: true
     #序列接口实现类配置
     key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
-    #逻辑删除配置
-    #logic-delete-value: 0
-    #logic-not-delete-value: 1
-    #自定义填充策略接口实现
-    #meta-object-handler: com.baomidou.springboot.xxx
-    #自定义SQL注入器
-    #sql-injector: com.king.security.mybatis.interceptor.DataSecurityInterceptor
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
@@ -73,11 +64,13 @@ log:
   path: log/
   level: debug
 
+# ftp信息
 ftp:
-  userName: yhjz_dev
-  password: dev@yhjz
-  ftpHostName: 117.50.20.112
+  userName: sailun_dev
+  password: sailun_dev@sailun
+  ftpHostName: 10.97.1.106
   port: 21
-  dataIp: http://117.50.20.112/
-  rootPath: /app/
-  httpAddr: http://117.50.20.112/upload/app/
+  dataIp: http://10.97.1.106/
+  rootPath: /sailun-allsteel-app/  #必须有"/"
+  httpAddr: https://b2bcnfile.sailuntire.com/upload/
+  tempDir: /application/temp

+ 1 - 1
sailun-allsteel-sys-provider/sailun-allsteel-sys-service/src/main/resources/banner.txt

@@ -1,5 +1,5 @@
 ====================================================================================================================
 
-             系统DUBBO - ------------------正在启动
+             赛轮全钢 系统DUBBO - ------------------正在启动
 
 ====================================================================================================================