package com.cku.util;

import org.springframework.util.StringUtils;

public class PedigreeCertifiedCodeUtil {

	public static void main(String[] args) {
//		String pedigreeCertifiedCode = "CKU 0001111";
		String pedigreeCertifiedCode = "Ng0001111";
		System.out.println(getCode(pedigreeCertifiedCode));
	}

	/**
	 * 血统证书号NG NGKC NGKC NG不展示
	 * 
	 * @return
	 */
	public static String getCode(String pedigreeCertifiedCode) {
		if (StringUtils.isEmpty(pedigreeCertifiedCode)) {
			return "";
		}
		pedigreeCertifiedCode = pedigreeCertifiedCode.toUpperCase();
		String NGKC_NG = "NGKC NG";
		String NGKCNG = "NGKCNG";
		String NGKC_ = "NGKC ";
		String NGKC = "NGKC";
		String NG_ = "NG ";
		String NG = "NG";
		int end = pedigreeCertifiedCode.length();
		if (pedigreeCertifiedCode.startsWith(NGKC_NG)) {
			return pedigreeCertifiedCode.substring(NGKC_NG.length(), end).trim() + "S";
		}
		if (pedigreeCertifiedCode.startsWith(NGKCNG)) {
			return pedigreeCertifiedCode.substring(NGKCNG.length(), end).trim() + "S";
		}
		if (pedigreeCertifiedCode.startsWith(NGKC_)) {
			return pedigreeCertifiedCode.substring(NGKC_.length(), end).trim() + "S";
		}
		if (pedigreeCertifiedCode.startsWith(NGKC)) {
			return pedigreeCertifiedCode.substring(NGKC.length(), end).trim() + "S";
		}
		if (pedigreeCertifiedCode.startsWith(NG_)) {
			return pedigreeCertifiedCode.substring(NG_.length(), end).trim() + "S";
		}
		if (pedigreeCertifiedCode.startsWith(NG)) {
			return pedigreeCertifiedCode.substring(NG.length(), end).trim() + "S";
		}
		return pedigreeCertifiedCode;
	}
}
