CustomMessageKit.java 1.5 KB
package com.framework.util;

import java.io.File;
import java.util.Date;

/**
 * Depiction:
 * <p>
 * Modify:
 * <p>
 * Author: William Lynn
 * <p>
 * Create Date:2018年6月7日 下午3:45:16
 * 
 */
public class CustomMessageKit {

	// smb://mrz:vmvnv1v2VV@10.50.3.61/nms_customs_xml2/
	public static String getMessageSmbRemoteDir() {
		StringBuilder sb = new StringBuilder();
		sb.append("smb://");
		String username = PropertiesLoader.get("custom.message.username", "/application.properties");
		sb.append(username + ":");
		String password = PropertiesLoader.get("custom.message.password", "/application.properties");
		sb.append(password + "@");
		String server = PropertiesLoader.get("custom.message.server", "/application.properties");
		sb.append(server + "/");
		String remotedir = PropertiesLoader.get("custom.message.remotedir", "/application.properties");
		sb.append(remotedir + "/");
		return sb.toString();
	}

	public static String getMessageLocalDir() {
		String dirPath = PropertiesLoader.get("custom.message.localdir", "/application.properties");
		File dir = new File(dirPath);
		if (dir == null || !dir.exists()) {
			dir.mkdirs();
		}
		return dirPath;
	}

	public static String getMessagePath(String prefix) {
		return getMessageLocalDir() + "/" + prefix + "_" + getMessageName();
	}

//	public static String getMessagePath() {
//		return getMessageLocalDir() + "/" + getMessageName();
//	}

	public static String getMessageName() {
		return "CN_MT2201_1P0_4604_70678920X_" + TimeUtils.getDate(new Date(), "yyyyMMddHHmmssSSS") + ".xml";
	}

}