Explorar o código

总体平台文件加密

guoyuanquan@mail.taiji.com.cn hai 1 mes
pai
achega
e71f2be53a

BIN=BIN
zwww-service/lib/btxa-crypto-sdk-1.0.jar


BIN=BIN
zwww-service/lib/mina-core-2.2.1.jar


BIN=BIN
zwww-service/lib/wst-bcprov-1.0.7.jar


BIN=BIN
zwww-service/lib/wst-common-util-1.0.5.jar


BIN=BIN
zwww-service/lib/wst-hsm-api-1.9.2.jar


BIN=BIN
zwww-service/lib/wst-sdk-2.6.2.jar


+ 121 - 7
zwww-service/pom.xml

@@ -19,6 +19,12 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>slf4j-api</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -41,13 +47,17 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>slf4j-api</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>cn.com.taiji</groupId>
             <artifactId>apione-http-client</artifactId>
             <version>1.0.0-SNAPSHOT</version>
-            <scope>system</scope>
-            <systemPath>${basedir}/lib/apione-http-client-1.0.0-SNAPSHOT.jar</systemPath>
         </dependency>
 
         <dependency>
@@ -56,11 +66,11 @@
             <version>1.2.75</version>
         </dependency>
 
-        <dependency>
-            <groupId>cn.hutool</groupId>
-            <artifactId>hutool-all</artifactId>
-            <version>5.6.6</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>cn.hutool</groupId>-->
+<!--            <artifactId>hutool-all</artifactId>-->
+<!--            <version>5.6.6</version>-->
+<!--        </dependency>-->
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -72,6 +82,95 @@
             <artifactId>commons-io</artifactId>
             <version>2.11.0</version>
         </dependency>
+
+
+        <dependency>
+            <groupId>com.btxa</groupId>
+            <artifactId>btxa-crypto-sdk</artifactId>
+            <version>1.0</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/lib/btxa-crypto-sdk-1.0.jar</systemPath>
+        </dependency>
+
+        <dependency>
+            <groupId>wst-bcprov</groupId>
+            <artifactId>wst-bcprov</artifactId>
+            <scope>system</scope>
+            <version>1.0.7</version>
+            <systemPath>${basedir}/lib/wst-bcprov-1.0.7.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>mina.core</groupId>
+            <artifactId>mina-core</artifactId>
+            <scope>system</scope>
+            <version>2.2.1</version>
+            <systemPath>${basedir}/lib/mina-core-2.2.1.jar</systemPath>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>slf4j.api</groupId>-->
+<!--            <artifactId>slf4j-api</artifactId>-->
+<!--            <version>0.0</version>-->
+<!--            <scope>system</scope>-->
+<!--            <systemPath>${basedir}/lib/slf4j-api-0.0.jar</systemPath>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>wst.common-util</groupId>
+            <artifactId>wst-common-util</artifactId>
+            <scope>system</scope>
+            <version>1.0.5</version>
+            <systemPath>${basedir}/lib/wst-common-util-1.0.5.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>wst.hsm.api</groupId>
+            <artifactId>wst-hsm-api</artifactId>
+            <version>1.9.2</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/lib/wst-hsm-api-1.9.2.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>wst.crypto.sdk</groupId>
+            <artifactId>wst-sdk</artifactId>
+            <version>2.6.2</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/lib/wst-sdk-2.6.2.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.6.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-client</artifactId>
+            <version>3.3.1</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>slf4j-api</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-hdfs</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-common</artifactId>
+            <version>3.3.1</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>slf4j-api</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>slf4j-log4j12</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
     </dependencies>
 
     <build>
@@ -84,6 +183,21 @@
                     <target>1.8</target>
                     <encoding>utf-8</encoding>
                 </configuration>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>prepare-package</phase>
+<!--                        <goals>-->
+<!--                            <goal>copy-dependencies</goal>-->
+<!--                        </goals>-->
+                        <configuration>
+                            <outputDirectory>${basedir}/lib</outputDirectory>
+                            <overWriteReleases>false</overWriteReleases>
+                            <overWriteSnapshots>false</overWriteSnapshots>
+                            <overWriteIfNewer>true</overWriteIfNewer>
+                        </configuration>
+                    </execution>
+                </executions>
             </plugin>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 39 - 0
zwww-service/src/main/java/cn/com/taiji/dataService/model/BtxaFileBo.java

@@ -0,0 +1,39 @@
+//package cn.com.taiji.dataService.model;
+//
+//import java.io.Serializable;
+//
+///**
+// * @author Ghh
+// */
+//public class BtxaFileBo implements Serializable {
+//    private boolean isFile;
+//    private String path;
+//    private String name;
+//
+//    public BtxaFileBo() {
+//    }
+//
+//    public boolean isFile() {
+//        return this.isFile;
+//    }
+//
+//    public void setFile(boolean file) {
+//        this.isFile = file;
+//    }
+//
+//    public String getPath() {
+//        return this.path;
+//    }
+//
+//    public void setPath(String path) {
+//        this.path = path;
+//    }
+//
+//    public String getName() {
+//        return this.name;
+//    }
+//
+//    public void setName(String name) {
+//        this.name = name;
+//    }
+//}

+ 27 - 0
zwww-service/src/main/java/cn/com/taiji/dataService/service/IBtxaeCryptoStorageService.java

@@ -0,0 +1,27 @@
+//package cn.com.taiji.dataService.service;
+//
+//import cn.com.taiji.dataService.model.BtxaFileBo;
+//import org.apache.hadoop.fs.FileSystem;
+//
+//import java.io.IOException;
+//import java.util.List;
+//
+//
+//public interface IBtxaeCryptoStorageService {
+//
+//    FileSystem login(String var1, String var2) throws IOException;
+//
+//    String read(String var1, String var2) throws IOException;
+//
+//    String write(String var1, String var2) throws Exception;
+//
+//    boolean mkdir(String var1);
+//
+//    boolean rm(String var1, boolean var2);
+//
+//    List<BtxaFileBo> ls(String var1);
+//
+//    List<BtxaFileBo> lsr(String var1);
+//
+//    void destroy();
+//}

+ 376 - 0
zwww-service/src/main/java/cn/com/taiji/dataService/service/impl/BtxaCryptoStorageServiceImpl.java

@@ -0,0 +1,376 @@
+//package cn.com.taiji.dataService.service.impl;
+//
+//import cn.com.taiji.dataService.model.BtxaFileBo;
+//import cn.com.taiji.dataService.service.IBtxaeCryptoStorageService;
+//import com.google.common.base.Strings;
+//import com.google.common.collect.Lists;
+//import java.io.BufferedInputStream;
+//import java.io.File;
+//import java.io.FileInputStream;
+//import java.io.FileNotFoundException;
+//import java.io.FileOutputStream;
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.security.PrivilegedExceptionAction;
+//import java.util.ArrayList;
+//import java.util.Iterator;
+//import java.util.List;
+//
+//import org.apache.hadoop.conf.Configuration;
+//import org.apache.hadoop.fs.*;
+//import org.apache.hadoop.io.IOUtils;
+//import org.apache.hadoop.security.UserGroupInformation;
+//import org.springframework.stereotype.Service;
+//
+///**
+// * @author Ghh
+// * @date 2025年03月03日 12:21
+// */
+//@Service
+//public class BtxaCryptoStorageServiceImpl   implements IBtxaeCryptoStorageService {
+//    public static final int ENCRYPTO_BLOCK_MIN_BYTE_SIZE = 16;
+//    private List<String> confFilePaths = Lists.newArrayList();
+//    private FileSystem fileSystem = null;
+//    private String username;
+//
+//    public BtxaCryptoStorageServiceImpl(String... confFilePaths) {
+//        this.confFilePaths = Lists.newArrayList(confFilePaths);
+//    }
+//
+//    private FileSystem getFiledSystem() throws IOException {
+//        if (null != this.fileSystem) {
+//            return this.fileSystem;
+//        } else {
+//            final Configuration conf = new Configuration();
+//            Iterator var2 = this.confFilePaths.iterator();
+//
+//            while(var2.hasNext()) {
+//                String filePath = (String)var2.next();
+//                File file = new File(filePath);
+//                if (file.exists()) {
+//                    conf.addResource(file.toURL());
+//                }
+//            }
+//
+//            if (Strings.isNullOrEmpty(this.username)) {
+//                this.fileSystem = FileSystem.get(conf);
+//            } else {
+//                UserGroupInformation ugi = UserGroupInformation.createRemoteUser(this.username);
+//                try {
+//                    this.fileSystem = (FileSystem)ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
+//                        @Override
+//                        public FileSystem run() throws Exception {
+//                            return FileSystem.get(conf);
+//                        }
+//                    });
+//                } catch (InterruptedException var5) {
+//                }
+//            }
+//
+//            return this.fileSystem;
+//        }
+//    }
+//
+//    @Override
+//    public FileSystem login(String username, String passwd) throws IOException {
+//        this.username = username;
+//        FileSystem filedSystem = this.getFiledSystem();
+//        return filedSystem;
+//    }
+//
+//    @Override
+//    public String read(String hdfsPath, String localPath) throws IOException {
+//        Path path = new Path(hdfsPath);
+//        boolean exists = this.getFiledSystem().exists(path);
+//        if (!exists) {
+//            throw new FileNotFoundException("hdfs filesystem file is not exists.path:" + hdfsPath);
+//        } else {
+//            boolean isFile = this.getFiledSystem().isFile(path);
+//            if (!isFile) {
+//                throw new IllegalArgumentException("hdfs filesystem path is not a file,cannot support not a file read.path:" + hdfsPath);
+//            } else {
+//                File localFile = new File(localPath);
+//                if (localFile.exists()) {
+//                    if (localFile.isFile()) {
+//                        throw new PathExistsException("local filesystem path exists.path:" + localPath);
+//                    }
+//
+//                    localPath = localPath + "/" + path.getName();
+//                    localFile = new File(localPath);
+//                }
+//
+//                boolean newFile = localFile.createNewFile();
+//                if (!newFile) {
+//                    throw new PathAccessDeniedException("cannot create new local file:" + localFile.getAbsolutePath());
+//                } else {
+//                    FSDataInputStream fsDataInputStream = null;
+//                    FileOutputStream fileOutputStream = null;
+//                    boolean var10 = false;
+//
+//                    try {
+//                        fsDataInputStream = this.getFiledSystem().open(path);
+//                        fileOutputStream = new FileOutputStream(localFile);
+//                        IOUtils.copyBytes(fsDataInputStream, fileOutputStream, 4096, false);
+//                    } catch (IOException var15) {
+//                    } finally {
+//                        IOUtils.closeStream(fileOutputStream);
+//                        IOUtils.closeStream(fsDataInputStream);
+//                        return localPath;
+//                    }
+//                }
+//            }
+//        }
+//    }
+//
+//    private boolean isAllEmptyBytes(byte[] bytes) {
+//        byte zero = bytes[0];
+//        int i = 1;
+//
+//        for(int len = bytes.length; i < len; ++i) {
+//            if (zero != bytes[i]) {
+//                return false;
+//            }
+//        }
+//
+//        return true;
+//    }
+//
+//    @Override
+//    public String write(String localPath, String hdfsPath) throws Exception {
+//        File file = new File(localPath);
+//        if (!file.exists()) {
+//            throw new PathExistsException("local filesystem path exists.path:" + localPath);
+//        } else if (!file.isFile()) {
+//            throw new FileNotFoundException("local filesystem path is directory,cannot support directory.path:" + localPath);
+//        } else {
+//            hdfsPath = this.getCheckPath(file.getName(), hdfsPath);
+//            Path hdfsFilePath = new Path(hdfsPath);
+//            FileInputStream fileInputStream = null;
+//            BufferedInputStream bufferedInputStream = null;
+//            String var7;
+//            try {
+//                fileInputStream = new FileInputStream(file);
+//                bufferedInputStream = new BufferedInputStream(fileInputStream);
+//                this.write((InputStream)bufferedInputStream, (Path)hdfsFilePath);
+//                var7 = hdfsPath;
+//            } catch (Throwable var12) {
+//                boolean delete = this.getFiledSystem().delete(hdfsFilePath, false);
+//                throw var12;
+//            } finally {
+//                IOUtils.closeStream(bufferedInputStream);
+//                IOUtils.closeStream(fileInputStream);
+//            }
+//            return var7;
+//        }
+//    }
+//
+//    private String getCheckPath(String name, String hdfsPath) throws IOException {
+//        Path hdfsFilePath = new Path(hdfsPath);
+//        boolean hdfsPathExists = this.getFiledSystem().exists(hdfsFilePath);
+//        boolean isDirDdfsPath = this.getFiledSystem().isDirectory(hdfsFilePath);
+//        if (hdfsPathExists) {
+//            if (!isDirDdfsPath) {
+//                String log = "hdfs path exists.path:" + hdfsPath;
+//                throw new PathExistsException(log);
+//            }
+//
+//            hdfsPath = hdfsPath + File.separator + name;
+//        }
+//
+//        return hdfsPath;
+//    }
+//
+//    private void write(InputStream localStream, Path hdfsPath) throws IOException {
+//        FSDataOutputStream outputStream = null;
+//        try {
+//            outputStream = this.getFiledSystem().create(hdfsPath);
+//            int buffSize = 4096;
+//            byte[] buf = new byte[buffSize];
+//            int bytesRead = localStream.read(buf);
+//
+//            for(int count = 0; bytesRead >= 0; bytesRead = localStream.read(buf)) {
+//                count += bytesRead;
+//                outputStream.write(buf, 0, bytesRead);
+//            }
+//        } finally {
+//            IOUtils.closeStream(outputStream);
+//        }
+//    }
+//
+//    @Override
+//    public boolean mkdir(String path) {
+//        try {
+//            return this.getFiledSystem().mkdirs(new Path(path));
+//        } catch (IOException var3) {
+//            return false;
+//        }
+//    }
+//
+//    @Override
+//    public boolean rm(String path, boolean isRecursive) {
+//        try {
+//            return this.getFiledSystem().delete(new Path(path), isRecursive);
+//        } catch (IOException var4) {
+//            return false;
+//        }
+//    }
+//
+//    @Override
+//    public List<BtxaFileBo> ls(String path) {
+//        ArrayList files = Lists.newArrayList();
+//
+//        try {
+//            RemoteIterator iterator = this.getFiledSystem().listLocatedStatus(new Path(path));
+//
+//            while(iterator.hasNext()) {
+//                BtxaFileBo btxaFileBo = new BtxaFileBo();
+//                LocatedFileStatus fileStatus = (LocatedFileStatus)iterator.next();
+//                btxaFileBo.setFile(fileStatus.isFile());
+//                btxaFileBo.setPath(fileStatus.getPath().toUri().getPath());
+//                btxaFileBo.setName(fileStatus.getPath().getName());
+//                files.add(btxaFileBo);
+//            }
+//        } catch (IOException var6) {
+//        }
+//
+//        return files;
+//    }
+//
+//    @Override
+//    public List<BtxaFileBo> lsr(String path) {
+//        ArrayList files = Lists.newArrayList();
+//
+//        try {
+//            RemoteIterator iterator = this.getFiledSystem().listFiles(new Path(path), true);
+//
+//            while(iterator.hasNext()) {
+//                BtxaFileBo btxaFileBo = new BtxaFileBo();
+//                LocatedFileStatus fileStatus = (LocatedFileStatus)iterator.next();
+//                btxaFileBo.setFile(fileStatus.isFile());
+//                btxaFileBo.setPath(fileStatus.getPath().toUri().getPath());
+//                btxaFileBo.setName(fileStatus.getPath().getName());
+//                files.add(btxaFileBo);
+//            }
+//        } catch (IOException var6) {
+//        }
+//
+//        return files;
+//    }
+//
+//    @Override
+//    public void destroy() {
+//        try {
+//            this.fileSystem.close();
+//        } catch (IOException var2) {
+//            var2.printStackTrace();
+//        }
+//
+//    }
+//
+//    public static void main(String[] args) throws Exception {
+//        String username = args[0];
+//        String methodName = args[1];
+//        List<String> confs = Lists.newArrayList(new String[]{"/home/hadoop/hadoop-3.2.1/etc/hadoop/core-site.xml","/home/hadoop/hadoop-3.2.1/etc/hadoop/hdfs-site.xml"});
+//        BtxaCryptoStorageServiceImpl btxaCryptoStorageService = new BtxaCryptoStorageServiceImpl((String[])confs.toArray(new String[0]));
+//        btxaCryptoStorageService.login(username, username);
+//        String lookDir = null;
+//        byte var7 = -1;
+//        switch(methodName.hashCode()) {
+//            case 3463:
+//                if (methodName.equals("ls")) {
+//                    var7 = 4;
+//                }
+//                break;
+//            case 3643:
+//                if (methodName.equals("rm")) {
+//                    var7 = 3;
+//                }
+//                break;
+//            case 107467:
+//                if (methodName.equals("lsr")) {
+//                    var7 = 5;
+//                }
+//                break;
+//            case 3496342:
+//                if (methodName.equals("read")) {
+//                    var7 = 0;
+//                }
+//                break;
+//            case 103950895:
+//                if (methodName.equals("mkdir")) {
+//                    var7 = 2;
+//                }
+//                break;
+//            case 113399775:
+//                if (methodName.equals("write")) {
+//                    var7 = 1;
+//                }
+//        }
+//
+//        switch(var7) {
+//            case 0:
+//                btxaCryptoStorageService.read(args[2], args[3]);
+//                System.out.println(String.format(">>>>>>read remote file:%s to local file:%s success.", args[2], args[3]));
+//                break;
+//            case 1:
+//                String write = btxaCryptoStorageService.write(args[2], args[3]);
+//                System.out.println(String.format(">>>>>>upload local file:%s to remote file:%s success.", args[2], args[3]));
+//                if (!write.equals(args[2])) {
+//                    System.out.println(">>>>>> !!! upload remote file name change to " + write);
+//                }
+//
+//                lookDir = args[3].substring(0, args[3].lastIndexOf("/") + 1);
+//                break;
+//            case 2:
+//                boolean mkdir = btxaCryptoStorageService.mkdir(args[2]);
+//                System.out.println(">>>>>>create dir is " + (mkdir ? "success" : "error"));
+//                lookDir = args[2].substring(0, args[2].lastIndexOf("/") + 1);
+//                break;
+//            case 3:
+//                boolean rm = btxaCryptoStorageService.rm(args[2], Boolean.getBoolean(args[3]));
+//                System.out.println(">>>>>>delete file or dir is " + (rm ? "success" : "error"));
+//                lookDir = args[2].substring(0, args[2].lastIndexOf("/") + 1);
+//                break;
+//            case 4:
+//                System.out.println(">>>>>>start look dir:" + args[2]);
+//                List<BtxaFileBo> ls = btxaCryptoStorageService.ls(args[2]);
+//                Iterator var17 = ls.iterator();
+//
+//                while(var17.hasNext()) {
+//                    BtxaFileBo file = (BtxaFileBo)var17.next();
+//                    System.out.println(file.getPath());
+//                }
+//
+//                System.out.println(">>>>>>end look dir:");
+//                break;
+//            case 5:
+//                List<BtxaFileBo> lsr = btxaCryptoStorageService.lsr(args[2]);
+//                System.out.println(">>>>>>start look dir all file and dir:");
+//                Iterator var14 = lsr.iterator();
+//
+//                while(var14.hasNext()) {
+//                    BtxaFileBo file = (BtxaFileBo)var14.next();
+//                    System.out.println(file.getPath());
+//                }
+//
+//                System.out.println(">>>>>>end look dir all file and dir.");
+//        }
+//
+//        System.out.println(">>>>>>run method " + methodName + " is done.");
+//        if (null != lookDir) {
+//            System.out.println(">>>>>>start look dir:" + lookDir);
+//            List<BtxaFileBo> ls = btxaCryptoStorageService.lsr(lookDir);
+//            Iterator var16 = ls.iterator();
+//
+//            while(var16.hasNext()) {
+//                BtxaFileBo file = (BtxaFileBo)var16.next();
+//                System.out.println(file.getPath());
+//            }
+//
+//            System.out.println(">>>>>>end look dir:");
+//        }
+//
+//        btxaCryptoStorageService.destroy();
+//        System.exit(0);
+//    }
+//}

+ 150 - 0
zwww-service/src/main/java/cn/com/taiji/dataService/task/ScheduleTJjd.java

@@ -0,0 +1,150 @@
+package cn.com.taiji.dataService.task;
+
+
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.btxa.crypto.IBtxaeCryptoStorageService;
+import com.btxa.crypto.impl.BtxaCryptoStorageServiceImpl;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+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.entity.BufferedHttpEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author Ghh
+ * @date 2025年03月20日 10:26
+ */
+@Component
+@Slf4j
+public class ScheduleTJjd {
+
+
+
+    @Scheduled(cron = "0 0 2 * * ?")
+//    @Scheduled(initialDelay = 1000, fixedDelay = 1000*200)
+    public void task() throws IOException {
+        JSONObject json1 = new JSONObject();
+        json1.put("sDate",DateUtil.format(DateUtil.yesterday(), "YYYYMMdd"));
+        json1.put("eDate",DateUtil.format(DateUtil.yesterday(), "YYYYMMdd"));
+        JSONObject json2 = new JSONObject();
+        json2.put("DT",DateUtil.format(DateUtil.yesterday(), "YYYY-MM-dd"));
+        JSONObject json3 = new JSONObject();
+        json3.put("TJ_DATE",DateUtil.format(DateUtil.yesterday(), "YYYYMMdd"));
+        sendApi("http://csb-broker.paas.sgpt.gov:8086/1.0.0/GXJHPTTCJK","AK618129bb65244187a58fffe160cc4c86","SK33d98b1cb793456aae5559b50803b98f","jtt_che_tong_ji","post",json1,"JCDCL");
+        sendApi("http://csb-broker.paas.sgpt.gov:8086/1.0.0/GXJHPTTCJK","AK4c7b6fb4b5f3414e91dd9d690ec7f633","SKc18c01dad89a4d4a95ba63078fc90798","api_RESULT_SHOP_STATISTICS_BYDT","get",json2,"LDMSSD");
+        sendApi("http://csb-broker.paas.sgpt.gov:8086/1.0.0/GXJHPTTCJK","AK860b60b5af814002932d3d10f74661f1","SK1860d6a7e076462681576e062fe5662b","DZZW_HZTLDSCJCDTJJK_STJJ","get",json3,"LDSCJCD");
+        sendGet("http://csb-broker.paas.sgpt.gov:8086/1.0.0/DZZW_RKJJCDHBTJXX_SGPT","RKJJCGHB");
+        sendGet("http://csb-broker.paas.sgpt.gov:8086/1.0.0/DZZW_JCDRYTJXX_SGPT","JCDRY");
+    }
+
+//    @Scheduled(cron = "0 10 2 * * ?")
+//    public void delWrite() throws IOException {
+//        File directory=  new File("D:/SGPTDATA/tmp");
+//        FileUtils.cleanDirectory(directory);
+//    }
+
+
+    /**
+     * [步骤 :1发送接口]
+     * post方法
+     */
+    public  void sendApi(String url, String ak, String sk, String api, String method, JSONObject json, String apiName) throws IOException {
+        JSONObject postJson = new JSONObject();
+        postJson.put("csbAk",ak);
+        postJson.put("csbSk",sk);
+        postJson.put("csbApi",api);
+        postJson.put("csbMethod",method);
+        postJson.put("reqJsonStr",json);
+        this.sendPost(url,postJson,apiName);
+    }
+
+    public void sendPost(String url, JSONObject json,String name) throws IOException {
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(url);
+        httpPost.setHeader("Content-type", "application/json; charset=utf-8");
+        StringEntity stringEntity = new StringEntity(json.toJSONString(), "UTF-8");
+        httpPost.setEntity(stringEntity);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        HttpEntity entity = response.getEntity();
+        HttpEntity bufferedHttpEntity = new BufferedHttpEntity(entity);
+        InputStream content = bufferedHttpEntity.getContent();
+        String fileName = name+ DateUtil.format(DateUtil.yesterday(), "YYYYMMdd")+".txt" ;
+        log.info(""+content);
+        this.writeFile(fileName,content);
+        response.close();
+        httpClient.close();
+    }
+
+    /**
+     * [步骤 :1发送接口]
+     * get方法
+     */
+    public void sendGet(String url,String name) throws IOException {
+        String day = DateUtil.format(DateUtil.yesterday(), "YYYYMMdd");
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        HttpGet httpGet = new HttpGet(url+"?date="+day);
+        CloseableHttpResponse response = httpClient.execute(httpGet);
+        HttpEntity entity = response.getEntity();
+        HttpEntity bufferedHttpEntity = new BufferedHttpEntity(entity);
+        InputStream content = bufferedHttpEntity.getContent();
+        String fileName = name+day+".txt" ;
+        this.writeFile(fileName,content);
+        response.close();
+        httpClient.close();
+    }
+
+
+    /**
+     * [步骤 :2存储文件]
+     */
+    public  void writeFile(String fileName, InputStream inputStream){
+        String path = "/SGPTDATA/tmp/"+fileName;
+        File outputFile = new File(path);
+        FileOutputStream outputStream = null;
+        try {
+            outputStream = new FileOutputStream(outputFile);
+            byte[] buffer = new byte[1024];
+            int bytesRead;
+            while ((bytesRead = inputStream.read(buffer)) != -1) {
+                outputStream.write(buffer, 0, bytesRead);
+            }
+            sdkWrite(path,fileName);
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                outputStream.close();
+                inputStream.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+    /**
+     * [步骤 :3转存文件]
+     */
+     List<String> conf = Lists.newArrayList("/home/hadoop/hadoop-3.2.1/etc/hadoop/core-site.xml",
+            "/home/hadoop/hadoop-3.2.1/etc/hadoop/hdfs-site.xml");
+    private  void sdkWrite(String filePath,String fileName) throws Exception {
+
+        IBtxaeCryptoStorageService iBtxaeCryptoStorageService =new BtxaCryptoStorageServiceImpl(conf.toArray(new String[]{}));
+        iBtxaeCryptoStorageService.login("taiji","taiji");
+        iBtxaeCryptoStorageService.write(filePath, "/SGPT_DATA/"+ fileName.substring(0,fileName.length()-4)+"/");
+    }
+}