package com.connor.ml.tcm.outfile.util;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;

import javax.swing.JOptionPane;


import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCClassificationService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentICO;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentProcess;
import com.teamcenter.rac.kernel.TCComponentProcessType;
import com.teamcenter.rac.kernel.TCComponentTaskTemplate;
import com.teamcenter.rac.kernel.TCComponentTaskTemplateType;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.kernel.ics.ICSKeyLov;
import com.teamcenter.rac.kernel.ics.ICSProperty;
import com.teamcenter.rac.kernel.ics.ICSPropertyDescription;
import com.teamcenter.rac.kernel.ics.ICSSearchResult;
import com.teamcenter.rac.util.MessageBox;
//import com.teamcenter.services.rac.core.DataManagementService;

//import net.sf.json.JSONArray;
//import net.sf.json.JSONObject;

public class MethodUtil {

	private static final String SEP1 = ",";

	/**
	 * 同步超级BOM
	 * 
	 * @param session     session
	 * @param process     流程对象
	 * @param processUser 节点负责人首选项的值
	 * @param arctic      车型
	 * @throws TCException
	 */
	public static void sendBom(TCSession session, TCComponentItemRevision itemRevision) throws TCException {

		TCUserService userservice = session.getUserService();

		Object[] obj = new Object[1];
		obj[0] = itemRevision;
		userservice.call("Super_Bom_Appent_Data", obj);
	}

	/**
	 * 根据规则获取ID
	 * 
	 * @param oldItemID 旧的ID
	 * @return 新的ID
	 */
	public static String getRuleItemID(TCSession session, String oldItemID) {
		// String[] oldItemIDs = oldItemID.split("-");
		DecimalFormat df = new DecimalFormat("000");
		// String newID = oldItemIDs[0] + "-" + oldItemIDs[1] + "-001";
		String newID = oldItemID + "-001";
		// String idTemp =
		TCComponentItemType tccomponentitemtype;
		try {
			tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("Item"));

			tccomponentitemtype.getNewID();
			int i = 1;
			while (tccomponentitemtype.find(newID) != null) {
				i++;
				// newID = oldItemIDs[0] + "-" + oldItemIDs[1] + "-"+ df.format(i);
				newID = oldItemID + "-" + df.format(i);
			}
		} catch (TCException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return newID;
	}

	/**
	 * List转换String
	 * 
	 * @param list :需要转换的List
	 * @return String转换后的字符串
	 */
	public static String ListToString(List<?> list) {

		StringBuffer sb = new StringBuffer();
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				if (list.get(i) == null || list.get(i) == "") {
					continue;
				}
				// 如果值是list类型则调用自己
				if (list.get(i) instanceof List) {
					sb.append(ListToString((List<?>) list.get(i)));
					sb.append(SEP1);
				} else {
					sb.append(list.get(i));
					sb.append(SEP1);
				}
			}
		}
		return sb.toString();
	}

//	// 获取组的lov值
//	public static String getGroupLov(TCSession session, String lovName, String key) {
//		try {
//			// 获取lov
//			TCComponentListOfValues rtlistOfValues = TCLOVUtil.findLOVByName(session, "TM2_GROUP");
//			ListOfValuesInfo rtlistOfValuesInfo = rtlistOfValues.getListOfValues();
//			String[] groupName = rtlistOfValuesInfo.getStringListOfValues();
//			String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues();
//			for (int i = 0; i < groupName.length; i++) {
//				if (groupName[i].equals(key)) {
//					return groupDisplayName[i];
//				}
//
//			}
//		} catch (TCException e) {
//			MessageBox.post("获取组的LOV错误！请联系系统管理员！", "错误！", MessageBox.ERROR);
//			e.printStackTrace();
//		}
//		return "";
//	}

	/**
	 * 获取模板文件
	 * @param session session
	 * @param fileName 文件名
	 * @param Filetype 文件类型
	 * @return
	 */
	public static File getFile(TCSession session,String fileName,String Filetype) {
		// TODO Auto-generated method stub
		try {
			TCPreferenceService service = session.getPreferenceService();
		      String[] modelFiles = service.getStringValues("ML_Doc_Teamplate");
		      if (modelFiles == null)
		      {
		        System.out.println("未找到首选项");
		        return null;
		      }
		      String itemId = "";
		      for (int i = 0; i < modelFiles.length; i++) {
				if(modelFiles[i].split(":")[0].equals(fileName))
				{
					itemId = modelFiles[i].split(":")[1];
				}
			  }
		      TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
		      TCComponentItem fileItem = itemType.find(itemId);
		      TCComponentDataset dat = null;
		      TCComponentItemRevision fileItemLastRev = getLastItemRevision(fileItem);
		      TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification");
				System.out.println("count =" + comps == null ? "null"
						: comps.length);
				// 遍历TC_Attaches关系下的所有对象
				for (TCComponent compt : comps) {
					// 获取对象类型
					String type = compt.getType();
					System.out.println(" TYPE = " + type);
					// 判断类型
					if (type.equals(type)) {
						dat = (TCComponentDataset)compt;
					}
				}
		      TCComponentTcFile[] tcFile = dat.getTcFiles();
		      if(tcFile != null && tcFile.length == 0)
		      {
		    	  System.out.println("未找到配置文件");
		      }
		      else
		      {
		    	  return tcFile[0].getFmsFile();
		      }
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 获取最新的已发布的版本
	 * 
	 * @param item
	 * @return
	 */
	public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) {
		// TODO Auto-generated method stub
		try {
			TCComponentItemRevision[] items = item.getReleasedItemRevisions();
			int revId = 0;
			TCComponentItemRevision itemRevision = null;
			for (int i = 0; i < items.length; i++) {
				String revisionId = items[i].getStringProperty("item_revision_id");
				if (letterToNumber(revisionId) >= revId) {
					itemRevision = items[i];
					revId = letterToNumber(revisionId);
				}
			}
			return itemRevision;
		} catch (TCException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	// 字母转数字 A-Z ：1-26
	public static int letterToNumber(String letter) {
		int length = letter.length();
		int num = 0;
		int number = 0;
		for (int i = 0; i < length; i++) {
			char ch = letter.charAt(length - i - 1);
			num = (int) (ch - 'A' + 1);
			num *= Math.pow(26, i);
			number += num;
		}
		return number;
	}

	/**
	 * 根据LOV名称获取LOV
	 * 
	 * @param tcsession
	 * @param s
	 * @return
	 */
	

	/**
	 * 根据LOV Key获取LOV值
	 * 
	 * @param tcsession
	 * @param s
	 * @return
	 */
	public static String findLovValueByKey(TCSession tcsession, String s, String key) {
		TCComponentListOfValues tccomponentlistofvalues = null;
		String resultValue = null;
		try {
			TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession
					.getTypeComponent("ListOfValues");
			TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s);
			if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) {
				tccomponentlistofvalues = atccomponentlistofvalues[0];

				ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues();

				String[] groupName = rtlistOfValuesInfo.getStringListOfValues();
				String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues();

				for (int i = 0; i < groupName.length; i++) {
					// resultMap.put(groupDisplayName[i],groupName[i]);
					if (groupName[i].equals(key)) {
						resultValue = groupDisplayName[i];
					}
				}
			}
		} catch (TCException tcexception) {
			tccomponentlistofvalues = null;
		}
		return resultValue;
	}

	/**
	 * 指派流程负责人
	 * 
	 * @param session     session
	 * @param process     流程对象
	 * @param processUser 节点负责人首选项的值
	 * @param arctic      车型
	 * @throws TCException
	 */
	public static void setProcess(TCSession session, TCComponentProcess process, String processUser, String arctic)
			throws TCException {

		TCUserService userservice = session.getUserService();

		Object[] obj = new Object[3];
		obj[0] = process;
		obj[1] = processUser;
		obj[2] = arctic;
		userservice.call("DMU_Review_Process", obj);
	}

	/**
	 * 指派适应性改型流程负责人
	 * 
	 * @param session     session
	 * @param process     流程对象
	 * @param processUser 节点负责人
	 * @param arctic      车型
	 * @throws TCException
	 */
	public static void setRemodelProcess(TCSession session, TCComponentProcess process, String processUser,
			String arctic) throws TCException {

		TCUserService userservice = session.getUserService();

		Object[] obj = new Object[3];
		obj[0] = process;
		obj[1] = processUser;
		obj[2] = arctic;
		userservice.call("Create_Remodel_Process", obj);
	}

	/**
	 * 获取单值得首选项
	 * 
	 * @param prefName
	 * @return
	 */
	public static String getPrefStr(String prefName) {
		AbstractAIFApplication app = AIFUtility.getCurrentApplication();
		TCSession session = (TCSession) app.getSession();
		TCPreferenceService service = session.getPreferenceService();
		String str = service.getString(TCPreferenceService.TC_preference_site, prefName);
		if (str == null) {
			str = new String("");
		}
		return str;
	}

	/***
	 * 获取首选项
	 * 
	 * @param session        会话
	 * @param preferenceName 首选项名称
	 * @return
	 */
	public static String[] getPreferenceValues(String preferenceName) {
		AbstractAIFApplication app = AIFUtility.getCurrentApplication();
		TCSession session = (TCSession) app.getSession();
		if (preferenceName == null || session == null) {
			System.out.println("");
			return null;
		}
		String[] values = null;
		TCPreferenceService service = session.getPreferenceService();
		values = service.getStringArray(TCPreferenceService.TC_preference_site, preferenceName);
		String[] resultValues = new String[values.length];
		for (int i = 0; i < values.length; i++) {
			if (values[i].indexOf("\\n") >= 0) {
				resultValues[i] = values[i].replace("\\n", "\n");
			} else {
				resultValues[i] = values[i];
			}
		}
		return resultValues;
	}

	/***
	 * 获取首选项
	 * 
	 * @param session        会话
	 * @param preferenceName 首选项名称
	 * @return
	 */
	public static String getPreferenceValue(String preferenceName) {
		AbstractAIFApplication app = AIFUtility.getCurrentApplication();
		TCSession session = (TCSession) app.getSession();
		if (preferenceName == null || session == null) {
			System.out.println("");
			return null;
		}
		TCPreferenceService service = session.getPreferenceService();
		return service.getString(TCPreferenceService.TC_preference_site, preferenceName);
	}
	
	public static void setByPass(boolean val,TCSession session) {
		try {
			TCUserService userservice = session.getUserService();
			userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" });
			System.out.println(val ? "Open Bypass" : "Close Bypass");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void openByPass(TCSession session) throws TCException {
		TCUserService userservice = session.getUserService();
		Object[] obj = new Object[1];
		obj[0] = "origin";
		userservice.call("CONNOR_open_bypass", obj);
	}

	public static void closeByPass(TCSession session) throws TCException {
		TCUserService userservice = session.getUserService();
		Object[] obj = new Object[1];
		obj[0] = "origin";
		userservice.call("CONNOR_close_bypass", obj);
	}
	public static void setProperty(TCSession session,TCComponent[] items,String propname,String propvalue) throws TCException {
		TCUserService userservice = session.getUserService();
		Object[] obj = new Object[3];
		obj[0] = items;
		obj[1] = propname;
		obj[2] = propvalue;
		userservice.call("connor_set_prop_value", obj);
	}

	/***
	 * 发送对象到分类（通过webService）
	 * 
	 * @param codeRemark 分类ID
	 * @param rev        版本对象
	 * @param propList   分类属性
	 */
	

	/***
	 * 将对象从分类中移除（通过webService）
	 * 
	 * @param codeRemark 分类对象的UID
	 */
	

	/***
	 * @param matnr 物料号
	 * @param ddlx  订单类型
	 * @param type  流程中订单、历史订单、废弃订单
	 * @return 返回分类id
	 */
	public static String getClassficationId(String matnr, String ddlx, String type) {
		// String classId = "jlcs01010101";
		String classId = "";
		if (ddlx.equals("车身") || ddlx.equals("KD")) {
			String[] values = getPreferenceValues("JL_number_to_className");
			String className = null;

			for (String s : values) {
				String[] split = s.split("=");
				if (split[0].equals(matnr)) {
					className = split[1];
					break;
				}
			}
			String[] values2 = getPreferenceValues("JL_name_to_id");
			// split[1]--历史，split[2]--流程 split[3]--废弃
			for (String t : values2) {
				String[] split = t.split("=");
				if (split[0].equals(className)) {
					if (type.equals("历史订单")) {
						classId = split[1];
					} else if (type.equals("流程中订单")) {
						classId = split[2];
					} else if (type.equals("废弃订单")) {
						classId = split[3];
					}
				}
			}
		} else if (ddlx.equals("配件")) {
			classId = "jlcs01010201";
			String name = matnr.substring(0, 2) + "配件";
			String[] values = getPreferenceValues("JL_name_to_id");
			for (String t : values) {
				String[] split = t.split("=");
				if (split[0].equals(name)) {
					if (type.equals("历史订单")) {
						classId = split[1];
					} else if (type.equals("流程中订单")) {
						classId = split[2];
					} else if (type.equals("废弃订单")) {
						classId = split[3];
					}
				}
			}
		}

		return classId;
	}

	/**
	 * 获取分类属性LOV显示值
	 * 
	 * @param icsD
	 * @return
	 */
	public static String getClassDisplayableValue(String value, ICSPropertyDescription icsD) {
		String result = "";
		ICSKeyLov lov1 = icsD.getFormat().getKeyLov();
		if (lov1 != null) {
			String[] keys = lov1.getKeys();
			for (String key : keys) {
				if (value.equals(key)) {
					result = lov1.getValueOfKey(key);
					return result;
				}
			}
		}
		return result;
	}

	public static boolean isDouble(String value) {
		try {
			Double.parseDouble(value);
			return true;
		} catch (Exception e) {
			// TODO: handle exception
			return false;
		}
	}

	/***
	 * 判断是否有权限
	 * 
	 * @param session session
	 * @param value   首选项名称
	 * @param userId  用户ID
	 * @return
	 */
	public static boolean havePrivilege(TCSession session, String commandName, String userId) {
		TCPreferenceService service = session.getPreferenceService();

		String[] values = service.getStringArray(TCPreferenceService.TC_preference_site, "JL_User_Rights");
		if (values == null || values.length == 0) {
			MessageBox.post("请配置首选项（管理权限）！请联系管理员", "错误", MessageBox.ERROR);
			return false;
		}
		for (String value : values) {
			// value = commandName + "——" + userId
			String[] split = value.split("——");
			if (split[0].equals(commandName)) {
				if (split.length == 1) {
					return true;
				} else {
					if (split[1].indexOf(userId) >= 0) {
						return true;
					} else {
						return false;
					}
				}
			}
		}
		return false;
	}

	public static int getCount(String mainStr, String subStr) {
		int minLength = mainStr.length();
		int subLength = subStr.length();
		int count = 0;
		int index = 0;

		if (minLength >= subLength) {
			while ((index = mainStr.indexOf(subStr, index)) != -1) {
				count++;
				index += subLength;
			}
			return count;
		}
		return 0;
	}

	/**
	 * 添加命名的引用
	 * 
	 * @param session
	 * @param item         对象的版本
	 * @param fileName     数据集名称
	 * @param tcResource   文件的物理路径
	 * @param isDelete     是否删除文件
	 * @param isReplace    是否删除原因数据集
	 */
	public static void setExcelToItem(TCSession session, TCComponentItemRevision item,String fileName, String tcResource,
			boolean isDelete,boolean isReplace) {
		try {
			String as1[] = { tcResource };// 文件的物理路径
			String as2[] = { "excel" };
			String as3[] = { "MSExcelX" };
			String as4[] = { "Plain" };
			TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session
					.getTypeComponent("Dataset");
			TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", "MSExcelX");
			tccomponentDataset.setFiles(as1, as3, as4, as2);
			//是否替換
			if(isReplace)
			{
				AIFComponentContext[] zyzdsChildrens = item.getChildren();
				TCComponentItemRevision zyzdsRev = item;
				for (AIFComponentContext zyzdsChildren : zyzdsChildrens) {
					if ("MSExcelX".equals(zyzdsChildren.getComponent().getType())) {
						TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent();
						zyzdsRev.remove("IMAN_specification", dateSet);
						dateSet.delete();
					}
				}
			}
			item.add("IMAN_specification", tccomponentDataset);
			if (isDelete) {
				new File(tcResource).delete();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static Object getTCPropertyValue(TCComponent item,String propertyName)
	{
		Object result = "";
		
		try {
			TCProperty tcProperty = item.getTCProperty(propertyName);
			if(tcProperty == null)
			{
				System.out.println("未获取属性："+propertyName);
				return result;
			}
			switch (tcProperty.getPropertyType()) {
			case TCProperty.PROP_double:
				result = tcProperty.getDoubleValue();
				break;
			case TCProperty.PROP_int:
				result = tcProperty.getIntValue();
				break;
			case TCProperty.PROP_string:
				result = tcProperty.getStringValue();
				break;
			case TCProperty.PROP_date:
				result = tcProperty.getDateValue();
				break;
			default:
				break;
			}
			
		} catch (TCException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return result;
	}
	public static void setTCPropertyValue(TCComponent item,String propertyName,Object value)
	{
		try {
			TCProperty tcProperty = item.getTCProperty(propertyName);
			switch (tcProperty.getPropertyType()) {
			case TCProperty.PROP_double:
				if(value instanceof Double)
				{
					tcProperty.setDoubleValue((double) value);
				}
				else
				{
					tcProperty.setDoubleValue(Double.parseDouble(value.toString()));
				}
				break;
			case TCProperty.PROP_int:
				if(value instanceof Integer)
				{
					tcProperty.setIntValue((int) value);
				}
				else
				{
					tcProperty.setIntValue(Integer.parseInt(value.toString()));
				}
				break;
			case TCProperty.PROP_string:
				tcProperty.setStringValue(value.toString());
				break;
			case TCProperty.PROP_date:
				if(value instanceof Date)
				{
					tcProperty.setDateValue((Date) value);
				}
				else
				{
					SimpleDateFormat sdf=new SimpleDateFormat("yyyy-M-dd HH:mm");
					tcProperty.setDateValue(sdf.parse(value.toString()));
				}
				break;
			default:
				break;
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 获取选取的ITEM的目标的信息
	 * 
	 * @param itemList
	 * @return
	 */
	
	
	/**
	 * 获取存放的文件夹
	 * 
	 * @param item
	 * @param name
	 * @return
	 */
	public static TCComponentFolder getParentFolder(TCComponentItem item,
			String name) {
		TCComponentFolder folder = null;
		try {
			AIFComponentContext[] comtexts = item.whereReferenced();
			if (comtexts != null) {
				for (int i = 0; i < comtexts.length; i++) {
					if (comtexts[i].getComponent() instanceof TCComponentFolder) {
						String nameT = ((TCComponentFolder) comtexts[i]
								.getComponent())
								.getStringProperty("object_name");
						if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) {
							folder = (TCComponentFolder) comtexts[i]
									.getComponent();
						}
						else if(nameT.equals(name))
						{
							folder = (TCComponentFolder) comtexts[i]
									.getComponent();
						}
					}
				}
			}
		} catch (TCException e) {
			e.printStackTrace();
		}
		return folder;
	}
	
	/**
	 * 过滤掉所有不需要显示的属性的
	 * 
	 * @param session
	 * @return
	 */

	
	/**
	 * 通过SOA创建ITEM对象
	 * 
	 * @param session
	 *            会话
	 * @param itemID
	 *            创建对象的ID
	 * @param itemRev
	 *            创建对象的版本
	 * @param itemType
	 *            创建对象的类型
	 * @param itemName
	 *            创建对象的名称
	 * @param itemDesc
	 *            创建对象的描述
	 * @param unit
	 *            创建对象的单位
	 * @param itemPropMap
	 *            创建对象的ITEM属性
	 * @param itemRevPropMap
	 *            创建对象的版本属性
	 * @param itemRevMasterPropMap
	 *            创建对象的版本表单属性
	 */
	
	
	public static void CreateProcess(TCSession session,TCComponent target,String processName) throws TCException {
		try {
			TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
			TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate");
			TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE);
			if (taskTemplate == null) {
				return;
			}
			// 创建一个流程 流程名称、描述、流程模板、目标对象、附件数
			String name = target.getProperty("object_string");
			processType.create(processName + "：" + name, "", taskTemplate, new TCComponent[] { target }, new int[] { 1 });
		} catch (TCException e) {
			e.printStackTrace();
			throw e;
		}
	}
	
	public static void CreateProcess(TCSession session,TCComponent[] targets,int[] type,String processName) throws TCException {
		try {
			TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
			TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate");
			TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE);
			if (taskTemplate == null) {
				return;
			}
			// 创建一个流程 流程名称、描述、流程模板、目标对象、附件数
			String name = targets[0].getProperty("object_string");
			processType.create(processName + "：" + name, "", taskTemplate, targets, type);
		} catch (TCException e) {
			e.printStackTrace();
			throw e;
		}
	}
	

	
	
	/**
	 * 读取EXCEL表
	 * 
	 * @param File excel_file
	 * @return List<DocDirectoryBean> 返回的信息
	 * @throws IOException
	 * @throws FileNotFoundException
	 */
	
	
	
	
	/**
	 * 读取EXCEL表
	 * 
	 * @param File excel_file
	 * @return List<DocDirectoryBean> 返回的信息
	 * @throws IOException
	 * @throws FileNotFoundException
	 */
	
	
	
	
	/**
	 * 读取EXCEL表
	 * 
	 * @param File excel_file
	 * @return List<DocDirectoryBean> 返回的信息
	 * @throws IOException
	 * @throws FileNotFoundException
	 */

	
}
