|
@@ -0,0 +1,52 @@
|
|
|
|
+package com.qmth.distributed.print;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
|
+
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+public class DownloadSign {
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
|
+ InputStream f1 = new FileInputStream("/Users/xiaofei/qmth/share-folder/image/1.txt");
|
|
|
|
+ InputStreamReader reader = new InputStreamReader(f1);
|
|
|
|
+ BufferedReader br = new BufferedReader(reader);
|
|
|
|
+ br.readLine(); //读取第一行且不作处理
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ String strTmp;
|
|
|
|
+ String imagePath = "/Users/xiaofei/qmth/share-folder/image";
|
|
|
|
+ while ((strTmp = br.readLine()) != null) {
|
|
|
|
+ String[] values = strTmp.split("&");
|
|
|
|
+ String packageCode = values[0];
|
|
|
|
+ String examPlace = values[1];
|
|
|
|
+ String examRoom = values[2];
|
|
|
|
+ String path = values[3];
|
|
|
|
+ String semester = values[4];
|
|
|
|
+ String exam = values[5];
|
|
|
|
+ String course = values[6];
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(path, JSONObject.class);
|
|
|
|
+ List<JSONObject> jsonObjectList = JSON.parseArray(jsonObject.getString("path"), JSONObject.class);
|
|
|
|
+
|
|
|
|
+ for (JSONObject object : jsonObjectList) {
|
|
|
|
+ if ("SIGN".equals(object.getString("printType"))) {
|
|
|
|
+ String filepath1 = imagePath + File.separator + "static" + File.separator + object.getString("pdfPath");
|
|
|
|
+ File file = new File(filepath1);
|
|
|
|
+ String filePath2 = imagePath + File.separator + "file" + File.separator + semester + File.separator + exam + File.separator + course;
|
|
|
|
+ String fileName = packageCode + "-" + examPlace + "-" + examRoom + ".pdf";
|
|
|
|
+ File file1 = new File(filePath2, fileName);
|
|
|
|
+ if (!file1.exists()) {
|
|
|
|
+ file1.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ FileUtils.copyFile(file, file1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ br.close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|