package com.seeyon.apps.src_contract.lease.kit;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;


/**
 * 读取参数
 */

public class PropKit {
	
	private static long lastModify;
	
	private static ConcurrentHashMap<String, String> props;
    
    public static final String PROFILE = "profile";
    
    public static final String LEASEURL = "leasrUrl";
    public static final String LEASEPROCEEDSURL = "leasrProceedsUrl";
    public static final String UPDATELEASEURL = "updateleasrUrl";
    public static final String PAYMENTPLANDETAILURL = "paymentplandetailUrl";
    public static final String LEASRTERMINATIONURL = "leasrTerminationUrl";
    public static final String LEASRTERMINATIONFKURL = "leasrTerminationfkUrl";
    public static final String LEASRDERATEURL = "leasrDerateUrl";
    public static final String FCTCHANGEPLANDETAILURL = "fctChangeplandetailUrl";

    public static final String RECEIVECONTRACTURL = "receivecontractUrl";
    public static final String PAYMENTCONTRACTURL = "paymentcontractUrl";
    public static final String TERMINATIONCONTRACTURL = "terminationcontractUrl";
    public static final String TERMINATIONFKCONTRACTURL = "terminationfkcontractUrl";
    public static final String HTPAYBILLSERVLETURL = "htpaybillServletUrl";
    
    public static final String PROD_LEASEURL = "prod.leaseUrl";
    public static final String PROD_LEASEPROCEEDSURL = "prod.leasrProceedsUrl";
    public static final String PROD_UPDATELEASEURL = "prod.updateleasrUrl";
    public static final String PROD_PAYMENTPLANDETAILURL = "prod.paymentplandetailUrl";
    public static final String PROD_LEASRTERMINATIONURL = "prod.leasrTerminationUrl";
    public static final String PROD_LEASRTERMINATIONFKURL = "prod.leasrTerminationfkUrl";
    public static final String PROD_LEASRDERATEURL = "prod.leasrDerateUrl";
    public static final String PROD_FCTCHANGEPLANDETAILURL = "prod.fctChangeplandetailUrl";
    
    public static final String PROD_RECEIVECONTRACTURL = "prod.receivecontractUrl";
    public static final String PROD_PAYMENTCONTRACTURL = "prod.paymentcontractUrl";
    public static final String PROD_TERMINATIONCONTRACTURL = "prod.terminationcontractUrl";
    public static final String PROD_TERMINATIONFKCONTRACTURL = "prod.terminationfkcontractUrl";
    public static final String PROD_PAYBILLSERVLETURL = "prod.paybillServletUrl";
    public static final String PROD_HTPAYBILLSERVLETURL = "prod.htpaybillServletUrl";

    /**
     * @return
     * @throws IOException 
     * @throws FileNotFoundException 
     */
    public static String getProp(String key) throws FileNotFoundException, IOException {
		File f = new File(A8FolderKit.getPropFile());
		if(null == props) {
			props = new ConcurrentHashMap<String, String>();
		}
		if(f.lastModified() != lastModify) {
			/**
			 * huangzhengguo 
			 * 2022-10-18
			 */
			Properties prop = new Properties();
			prop.load(new FileInputStream(f));
//			Properties prop = PropertiesUtil.getFromFile((CtpLocalFile) f);
			/**
			 * end
			 */
			String profile = prop.getProperty(PROFILE);
			if("prod".equals(profile)) {
				props.put(LEASEURL, prop.getProperty(PROD_LEASEURL));
				props.put(LEASEPROCEEDSURL, prop.getProperty(PROD_LEASEPROCEEDSURL));
				props.put(UPDATELEASEURL, prop.getProperty(PROD_UPDATELEASEURL));
				props.put(PAYMENTPLANDETAILURL, prop.getProperty(PROD_PAYMENTPLANDETAILURL));
				props.put(LEASRTERMINATIONURL, prop.getProperty(PROD_LEASRTERMINATIONURL));
				props.put(LEASRTERMINATIONFKURL, prop.getProperty(PROD_LEASRTERMINATIONFKURL));
				props.put(LEASRDERATEURL, prop.getProperty(PROD_LEASRDERATEURL));
				props.put(FCTCHANGEPLANDETAILURL, prop.getProperty(PROD_FCTCHANGEPLANDETAILURL));
			
				props.put(RECEIVECONTRACTURL, prop.getProperty(PROD_RECEIVECONTRACTURL));
				props.put(PAYMENTCONTRACTURL, prop.getProperty(PROD_PAYMENTCONTRACTURL));
				props.put(TERMINATIONCONTRACTURL, prop.getProperty(PROD_TERMINATIONCONTRACTURL));
				props.put(TERMINATIONFKCONTRACTURL, prop.getProperty(PROD_TERMINATIONFKCONTRACTURL));
				props.put(HTPAYBILLSERVLETURL, prop.getProperty(PROD_HTPAYBILLSERVLETURL));
			
			} else {
				props.put(LEASEURL, prop.getProperty(PROD_LEASEURL));
				props.put(LEASEPROCEEDSURL, prop.getProperty(PROD_LEASEPROCEEDSURL));
				props.put(UPDATELEASEURL, prop.getProperty(PROD_UPDATELEASEURL));
				props.put(PAYMENTPLANDETAILURL, prop.getProperty(PROD_PAYMENTPLANDETAILURL));
				props.put(LEASRTERMINATIONURL, prop.getProperty(PROD_LEASRTERMINATIONURL));
				props.put(LEASRTERMINATIONFKURL, prop.getProperty(PROD_LEASRTERMINATIONFKURL));
				props.put(LEASRDERATEURL, prop.getProperty(PROD_LEASRDERATEURL));
				props.put(FCTCHANGEPLANDETAILURL, prop.getProperty(PROD_FCTCHANGEPLANDETAILURL));
				
				props.put(RECEIVECONTRACTURL, prop.getProperty(PROD_RECEIVECONTRACTURL));
				props.put(PAYMENTCONTRACTURL, prop.getProperty(PROD_PAYMENTCONTRACTURL));
				props.put(TERMINATIONCONTRACTURL, prop.getProperty(PROD_TERMINATIONCONTRACTURL));
				props.put(TERMINATIONFKCONTRACTURL, prop.getProperty(PROD_TERMINATIONFKCONTRACTURL));
				props.put(HTPAYBILLSERVLETURL, prop.getProperty(PROD_HTPAYBILLSERVLETURL));
			
			}
		}
		return props.get(key);
    }
  
}
