|
@@ -74,56 +74,56 @@ public class DataService {
|
|
|
* @param instutionId
|
|
|
* @param number
|
|
|
*/
|
|
|
- public void saveAnnex(Map <String,String> map, String filePath) {
|
|
|
- String newUrl = filePath.replaceAll("\\\\", "/") ;
|
|
|
- String fileNameStr[] = newUrl.split("/");
|
|
|
- String fileName = fileNameStr[fileNameStr.length-1];
|
|
|
- String fileStorePath =getFileWithUrl(newUrl, fileName);
|
|
|
- File file =new File(fileStorePath);
|
|
|
- String eTag = getFileMd5(file);
|
|
|
- String key = PropKit.get("institution_id")+"/"+eTag+".pdf";
|
|
|
-
|
|
|
- Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
- if (!eBoolean) {
|
|
|
- OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, file);
|
|
|
- Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
- if (bBoolean) {
|
|
|
- file.delete();
|
|
|
- map.put("url", "https://annex.oss.cn-north-3.inspurcloudoss.com/"+key);
|
|
|
- map.put("name", key);
|
|
|
- postWithParameters(SAVE_ANNEX_URL, map);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private String getFileMd5(File file) {
|
|
|
- StringBuffer sb = new StringBuffer("");
|
|
|
- try {
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
- md.update(FileUtils.readFileToByteArray(file));
|
|
|
- byte b[] = md.digest();
|
|
|
- int d;
|
|
|
- for (int i = 0; i < b.length; i++) {
|
|
|
- d = b[i];
|
|
|
- if (d < 0) {
|
|
|
- d = b[i] & 0xff;
|
|
|
- // 与上一行效果等同
|
|
|
- // i += 256;
|
|
|
- }
|
|
|
- if (d < 16)
|
|
|
- sb.append("0");
|
|
|
- sb.append(Integer.toHexString(d));
|
|
|
- }
|
|
|
- System.out.println(sb);
|
|
|
-
|
|
|
- } catch (NoSuchAlgorithmException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
+// public void saveAnnex(Map <String,String> map, String filePath) {
|
|
|
+// String newUrl = filePath.replaceAll("\\\\", "/") ;
|
|
|
+// String fileNameStr[] = newUrl.split("/");
|
|
|
+// String fileName = fileNameStr[fileNameStr.length-1];
|
|
|
+// String fileStorePath =getFileWithUrl(newUrl, fileName);
|
|
|
+// File file =new File(fileStorePath);
|
|
|
+// String eTag = getFileMd5(file);
|
|
|
+// String key = PropKit.get("institution_id")+"/"+eTag+".pdf";
|
|
|
+//
|
|
|
+// Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+// if (!eBoolean) {
|
|
|
+// OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, file);
|
|
|
+// Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+// if (bBoolean) {
|
|
|
+// file.delete();
|
|
|
+// map.put("url", "https://annex.oss.cn-north-3.inspurcloudoss.com/"+key);
|
|
|
+// map.put("name", key);
|
|
|
+// postWithParameters(SAVE_ANNEX_URL, map);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// private String getFileMd5(File file) {
|
|
|
+// StringBuffer sb = new StringBuffer("");
|
|
|
+// try {
|
|
|
+// MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
+// md.update(FileUtils.readFileToByteArray(file));
|
|
|
+// byte b[] = md.digest();
|
|
|
+// int d;
|
|
|
+// for (int i = 0; i < b.length; i++) {
|
|
|
+// d = b[i];
|
|
|
+// if (d < 0) {
|
|
|
+// d = b[i] & 0xff;
|
|
|
+// // 与上一行效果等同
|
|
|
+// // i += 256;
|
|
|
+// }
|
|
|
+// if (d < 16)
|
|
|
+// sb.append("0");
|
|
|
+// sb.append(Integer.toHexString(d));
|
|
|
+// }
|
|
|
+// System.out.println(sb);
|
|
|
+//
|
|
|
+// } catch (NoSuchAlgorithmException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return sb.toString();
|
|
|
+// }
|
|
|
|
|
|
public static String postWithParameters(String url, Map<String, String> map) {
|
|
|
|