package nccloud.web.hrhi.psndoc.vo;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.Vector;

import org.apache.commons.io.IOUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import nc.bs.logging.Logger;
import nc.hr.utils.HRFileUtils;
import nc.hr.utils.ResHelper;
import nc.itf.hr.wa.ISalaryadjmgtConstant;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.pub.bill.IBillItem;
import nc.vo.bd.defdoc.DefdocVO;
import nc.vo.hi.psndoc.TrainVO;
import nc.vo.hr.dataio.Validator;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.lang.UFLiteralDate;
import nccloud.base.exception.ExceptionUtils;
import nccloud.commons.lang.StringUtils;
import nccloud.framework.service.ServiceLocator;
import nccloud.web.hrwa.helper.DeleteFileUtil;
import nccloud.web.hrwa.pub.ErrorContent;
import uap.lfw.md.vo.EnumValueVO;

/**
 * 培训子集 导入数据
 * 
 * @author lenovo
 *
 */
public class TrainPsndocXlsImport {

	public ImportBean importFormFile(InputStream fileInput, List<Map<String, Object>> headList, String fileName,
			String pk_group, String pk_org, String pk_loginUser) throws BusinessException {
		ImportBean importBean = new ImportBean();
		FileOutputStream fileOut = null;
		// 表头
		Vector<Map<String, Object>> headVector = new Vector<>();
		// 数据
		Vector<TrainVO> vector = new Vector<TrainVO>();
		try {
			boolean error = true;
			if (null == fileInput || StringUtils.isBlank(fileName)) {
				return null;
			}
			if (!fileName.endsWith(".xls") && !fileName.endsWith(".xlsx")) {
				ExceptionUtils.wrapBusinessException(ErrorContent.FILETYPEERROR);
			}
			String version = fileName.endsWith(".xls") ? "2003" : "2007";
			Workbook wb = null;
			if (version.equals("2003")) {
				wb = new HSSFWorkbook(fileInput);
			} else if (version.equals("2007")) {
				wb = new XSSFWorkbook(fileInput);
			}
			Sheet sheet = wb.getSheetAt(0);
			TrainVO vo = null;
			// 当前行数据
			Row row = null;
			// 当前单元格对象
			Cell cell = null;
			// 当前单元格的内容
			String sValue = null;
			// 模板上的所有ITEMs
			int index = 0;
			StringBuffer sbMessage = null;

			// 循环处理每一行数据
			for (int currentSequence = 0; currentSequence <= sheet.getLastRowNum(); currentSequence++) {
				// 行数据验证消息
				sbMessage = new StringBuffer();
				try {
					vo = new TrainVO();

					// 处理行号
					boolean linflag = false;
					int offset = 0;// 有行号，则产生偏移
					if (!linflag) {
						offset++;
						linflag = true;
					}
					int offset2 = offset - 2;

					// 处理表头
					if (currentSequence == 0) {
						for (int currentColumn = 0; currentColumn < headList.size(); currentColumn++) {
//							if ((currentColumn == 2 || currentColumn == 3) && !allowed.booleanValue()) {
//								continue;
//							}
//							if (currentColumn > 3 && !allowed.booleanValue()) {
//								offset = offset2;
//							}
							headVector.add(headList.get(currentColumn));
						}
						importBean.setHeadVector(headVector);
						continue;
					}
					// 得到一行数据
					row = sheet.getRow(currentSequence);

					for (int currentColumn = 0; currentColumn < headList.size(); currentColumn++) {
//						if ((currentColumn == 1)) {
//							continue;
//						}
						if (currentColumn > 3) {
//							offset = offset2;
						}
						// 循环处理每一个单元格
						cell = row.getCell((short) (currentColumn + offset));
						if (cell == null) {
							cell = row.createCell((short) (currentColumn + offset));
						}
						sValue = this.getCellValue(cell);
						sValue = sValue == null ? "" : sValue.trim();

						// 验证数据是否正确
						if (!this.checkData(headList.get(currentColumn), sValue, sbMessage)) {
							this.renderCell(cell, wb);
							error = false;
						} else {
							int dataType = (Integer) headList.get(currentColumn).get("dataType");
							//人员编码
							if("psnCode".equals(headList.get(currentColumn).get("key"))) {
								vo.setPsnCode(sValue);
								vo.setAttributeValue("pk_psndoc",this.getValue(headList.get(currentColumn), sValue).toString());
							}else if("psnName".equals(headList.get(currentColumn).get("key"))) {
								vo.setPsnName(sValue);
							}else if(dataType == 5) {
								//自定义档案
								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",
										this.getValue(headList.get(currentColumn), sValue));
							}else if(dataType == 6) {
								//枚举
								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",
										this.getValue(headList.get(currentColumn), sValue));
							}
//							else if ("tra_type".equals(headList.get(currentColumn).get("key")) || "tra_mode".equals(headList.get(currentColumn).get("key"))) {
//								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",this.getValue(headList.get(currentColumn), sValue).toString());
//							} else if ("source_type".equals(headList.get(currentColumn).get("key"))) {
//								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",this.getSourceType().get(sValue) == null ? sValue : this.getSourceType().get(sValue));
//							} else if ("taketrm_method".equals(headList.get(currentColumn).get("key"))) {
//								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",this.getTaketrmMethod().get(sValue) == null ? sValue : this.getTaketrmMethod().get(sValue));
//							} 
//							else if ("absence_count".equals(headList.get(currentColumn).get("key")) || "tra_time".equals(headList.get(currentColumn).get("key"))) { 
//								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",Integer.valueOf(sValue == null ? "0" : sValue.toString().replaceAll("\\.0", "")));
//							} 
							else {
								vo.setAttributeValue(headList.get(currentColumn).get("key") + "",
										this.getValue(headList.get(currentColumn), sValue));
							}
						}
					}

					// ------------------设置默认值--------------------
					vo.setAttributeValue(TrainVO.PK_GROUP, pk_group);
					vo.setAttributeValue(TrainVO.PK_ORG, pk_org);
					// 是否是来自于流程 N 手工加入
//					vo.setAttributeValue(PsndocWadocVO.WORKFLOWFLAG, UFBoolean.valueOf(false));
//					// 业务类型 1：定级；
//					vo.setAttributeValue(PsndocWadocVO.IADJUSTMATTER, 1);
					String strErrorMessage = sbMessage.toString();
					if (!StringUtils.isBlank(strErrorMessage)) {
						// 2015-11-21 zhousze 错误信息列应该在最后一列 为第19列 begin
						// 20150911 xiejie3
						// NCdp205468851错误信息写入excel时，由于列从0开始创建，所以应该减去1，又由于前面不知为啥要加1，所以减去2.
						cell = row.createCell(headList.size()+1, CellType.STRING);
						// end
						cell.setCellValue(strErrorMessage);

					}
					vo.setAttributeValue("reason", strErrorMessage);
				} catch (Exception ex) {
					continue;
				}
				vector.add(vo);
			}
			importBean.setVector(vector);
			if (!error) {
				String filePath = HRFileUtils.getExportPath() + "/hrhifile/psndoc/errorfile/";
				// 删除过期文件
				DeleteFileUtil.delete(filePath);
				// 将错误文件保存在服务器上
				String name = UUID.randomUUID().toString() + ".xls";
				String errorFileName = filePath + pk_loginUser + "/" + name;

				File file = new File(errorFileName);
				if (!file.isDirectory()) {
					file.mkdirs();
				}
				if (file.exists()) {
					file.delete();
				}
				fileOut = new FileOutputStream(file);
				wb.write(fileOut);
				importBean.setError(error);
				/* @res "源文件数据存在错误，错误数据已经用红色字体标注，请仔细检查！" */
				importBean.setErrorMessage(ResHelper.getString("6013datainterface", "06013datainterface0121"));
				importBean.setErrorFile(name);
			}
		} catch (IOException e) {
			Logger.error(e.getMessage(), e);
            throw new BusinessException(ResHelper.getString("6001hrimp", "06001hrimp0235")/* @res "文件读取错误!" */);
		} finally {
			IOUtils.closeQuietly(fileInput);
			IOUtils.closeQuietly(fileOut);
		}
		return importBean;
	}

	/**
	 * 核查单元值是否合法 如果不合法，则将相应的单元cell 变为红色
	 *
	 * @param item
	 * @param aValue
	 * @return
	 */
	private boolean checkData(Map<String, Object> headMap, String aValue, StringBuffer sbMessage) {
		if (aValue == null) {
			aValue = "";
		}
		// 当心类型不统一
		int datatype = (Integer) headMap.get("dataType");
		String strItemKey = (String) headMap.get("key");
		int length = (Integer) headMap.get("width");
		int decimals = (Integer) headMap.get("length");
		String name = (String) headMap.get("name");
		// 检验是否通过
		boolean isLost = true;

		if (!this.notNullValidator(headMap, aValue, name, sbMessage)) {
			return false;
		}

		String nullable = (String) headMap.get("nullable");
		if("Y".equals(nullable)) {
			if(StringUtils.isBlank(aValue)) {
				return isLost;
			}
		}
		
		// 数据格式校验
		switch (datatype) {
		case IBillItem.DECIMAL:// 数值型
			// -----为设置精度增加的代码，对于小数的增加如下监听------------------
			if (!Validator.isUFDouble(aValue.toString().trim())) {
				isLost = false;
				sbMessage.append("[{"+aValue+"}] 不是数值类型 不符合设定的格式!");
			} else {
				// 验证数据长度与小数位数
				// 数据长度是指整数部分的长度,小数位数是指小数位的长度
				int digitsLength = 0;// 小数位数默认为0;
				int intLength = 0;// 整数长度默认是0
				int dotPosition = aValue.toString().trim().indexOf(ISalaryadjmgtConstant.POINT);// 小数点的位置
				if (decimals > 0) {// 因为设置列的数据长度=整数位数+小数位数+1,所以这里进行还原.
					length = length - decimals - 1;
				}
				if (dotPosition > 0) {
					digitsLength = aValue.toString().trim().substring(dotPosition).length() - 1;
					intLength = aValue.toString().trim().substring(0, dotPosition).length();
				} else {// 没有小数
					digitsLength = 0;
					intLength = aValue.toString().trim().length();
				}
				// 验证数据长度,小数位数
				if (intLength > length || digitsLength > decimals) {
					isLost = false;
					sbMessage.append("[{"+aValue+"}]数据长度或者小数位数  不符合设定的格式!");
				}
			}
			break;
		case IBillItem.BOOLEAN:
			if (!Validator.isUFBoolean(aValue.toString().trim()) || (!"N".equals(aValue.toString().trim()) && !"Y".equals(aValue.toString().trim()))) {
				isLost = false;
				sbMessage.append("[{"+aValue+"}]不符合设定的格式  输入的内容必须是{N}或者{Y}!");
			} else {// 验证数据长度
				if (aValue.toString().length() > length) {
					isLost = false;
					sbMessage.append("[{"+aValue+"}]数据长度  不符合设定的格式!");
				}
			}

			// 谈判工资肯定在 薪资级别和薪资档别之前
//			if (PsndocWadocVO.NEGOTIATION_WAGE.equalsIgnoreCase(strItemKey)) {
//				isNegotiation_wage = UFBoolean.valueOf(aValue.toString()).booleanValue();
//			}

			break;
		case IBillItem.DATE:
			if (StringUtils.isBlank(aValue.toString()) || !this.isUFDate(aValue.toString())) {
				isLost = false;
				sbMessage.append("[{"+aValue+"}]不是日期类型，不符合设定的格式!");
			} else {// 验证数据长度
				if (aValue.toString().length() > decimals) {
					isLost = false;
					sbMessage.append("[{"+aValue+"}]数据长度不正确，不符合设定的格式!");
				}
			}
			break;
		case IBillItem.LITERALDATE:
			if (StringUtils.isBlank(aValue.toString()) || !this.isUFDate(aValue.toString())) {
				isLost = false;
				sbMessage.append("[{"+aValue+"}]不是日期类型，不符合设定的格式!");
			} else {// 验证数据长度
				if (aValue.toString().length() > decimals) {
					isLost = false;
					sbMessage.append("[{"+aValue+"}]数据长度不正确，不符合设定的格式!");
				}
			}
			break;
		case IBillItem.UFREF:
			Object pk_defdoc = this.getValue(headMap, aValue);
			if(pk_defdoc == null || "".equals(pk_defdoc)) {
				isLost = false;
				sbMessage.append("[{"+aValue+"}]"+headMap.get("name")+"在自定义档案中找不到对应数据!");
			}
			break;
		// 字符串型不需要解析！因为 aValue 就是一个字符串！
		default:
			if (aValue.toString().length() > decimals && !"taketrm_method".equals(strItemKey) && !"source_type".equals(strItemKey)) {
				// 验证数据长度
				isLost = false;
				sbMessage.append("[{"+aValue+"}]数据长度不正确，不符合设定的格式!");
			}
			break;
		}
		
		if("psnCode".equals(strItemKey)) {
			Object pk_psndoc = this.getValue(headMap, aValue);
			if(pk_psndoc == null || "".equals(pk_psndoc)) {
				// 验证人员编码是否存在
				isLost = false;
				sbMessage.append("[{"+aValue+"}]人员编码系统中找不到对应数据!");
			}
		}

//		if("tra_type".equals(strItemKey)) {
//			Object tra_type = this.getValue(headMap, aValue);
//			if(tra_type == null || "".equals(tra_type)) {
//				isLost = false;
//				sbMessage.append("[{"+aValue+"}]培训类别在自定义档案中找不到对应数据!");
//			}
//		}else if("tra_mode".equals(strItemKey)) {
//			Object tra_mode = this.getValue(headMap, aValue);
//			if(tra_mode == null || "".equals(tra_mode)) {
//				isLost = false;
//				sbMessage.append("[{"+aValue+"}]培训方式在自定义档案中找不到对应数据!");
//			}
//		}
		
		if (!isLost) {
			sbMessage.append("\n");
		}
		return isLost;
	}
	
	/**
     * 验证一个字符串是合法的UFDate
     * @param strDate
     * @return
     */
    private boolean isUFDate(String strDate)
    {
        if (StringUtils.isBlank(strDate))
        {
            return false;
        }
        try
        {
        	if (strDate.length() == 10)
        	{
        		UFDate date = new UFDate(strDate);
        	}
        	else if (strDate.length() == 19)
        	{
        		UFDateTime date = new UFDateTime(strDate);
        	}
        	else
        	{
        		return false;
        	}
        	
        }
        catch (Exception e)
        {
            return false;
        }

        return true;
    }

	/**
	 * 读取cell中的内容<BR>
	 * <BR>
	 *
	 * @author xuhw on 2010-4-12
	 * @param cell
	 * @return
	 * @throws ParseException
	 */
	private String getCellValue(Cell cell) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		if (cell == null) {
			return "";
		}
		CellType type = cell.getCellType();
		String value = "";
		switch (type) {
			case NUMERIC:
			if (HSSFDateUtil.isCellDateFormatted(cell)) {
				value = sdf.format(cell.getDateCellValue());
				break;
			}
			value = String.valueOf(cell.getNumericCellValue());
			if (value.indexOf("E") > 0) {
				value = parseDouble(value);
			}
			break;
			case STRING:
			value = cell.getStringCellValue();
			break;
			case BOOLEAN:
			value = String.valueOf(cell.getBooleanCellValue());
			break;
		default:
		}
		return value;
	}

	/**
	 * 处理数值型的科学计数法
	 *
	 * @author xuhw on 2010-8-3
	 * @param strDigt
	 * @return
	 */
	private String parseDouble(String strDigt) {
		int pos = strDigt.indexOf("E");
		int dotPos = strDigt.indexOf(".");
		String betweenValue = strDigt.substring(dotPos + 1, pos);
		String temp = "";
		int power = Integer.parseInt(strDigt.substring(pos + 1));
		if (power > 0) {
			StringBuilder sbd = new StringBuilder();
			sbd.append(strDigt.substring(0, dotPos));
			for (int index = 0; index < power; index++) {
				if (index < betweenValue.length()) {
					sbd.append(betweenValue.charAt(index));
				} else {
					sbd.append("0");
				}
			}

			if (power < betweenValue.length()) {
				temp = betweenValue.substring(power);
				sbd.append((new StringBuilder()).append(".").append(temp).toString());
			}
			return sbd.toString();
		} else {
			return strDigt;
		}
	}

	/**
	 * 导入文件数据非空校验
	 *
	 * @author xuhw on 2010-4-23
	 * @param strItemKey
	 * @param aValue
	 * @param name
	 * @param sbMessage
	 * @return
	 */
	private boolean notNullValidator(Map<String, Object> headMap, String aValue, String name, StringBuffer sbMessage) {
		// 谈判工资，档别 级别 必须为空， 其它都为非空
		boolean isLost = true;
		
		String nullable = (String) headMap.get("nullable");
		
		if("N".equals(nullable)) {
			if(StringUtils.isBlank(aValue)) {
				sbMessage.append(headMap.get("name")+"不能为空");
				return false;
			}
		}
//		if (TrainVO.ACT_NAME.equalsIgnoreCase((String)headMap.get("key")) && StringUtils.isBlank(aValue)) {
//			sbMessage.append("培训活动名称不能为空");
//			return false;
//		}
//		if (TrainVO.TRA_TYPE.equalsIgnoreCase(strItemKey) && StringUtils.isBlank(aValue)) {
//			sbMessage.append("培训类别不能为空");
//			return false;
//		}
//		if ("psnCode".equalsIgnoreCase(strItemKey) && StringUtils.isBlank(aValue)) {
//			sbMessage.append("人员编码不能为空");
//			return false;
//		}

		if (!isLost) {
			sbMessage.append("\n");
			return false;
		}

		return isLost;
	}

	private Cell renderCell(Cell cell, Workbook wb) {
		CellStyle titleCellStyle = wb.createCellStyle();
		Font font = wb.createFont();
		font.setColor(Font.COLOR_RED);
		titleCellStyle.setFont(font);
//		titleCellStyle.setFillBackgroundColor(IndexedColors.RED.getIndex());
//		titleCellStyle.setFillForegroundColor(IndexedColors.RED.getIndex());// 设置背景色
//		titleCellStyle.setFillForegroundColor(IndexedColors.CORNFLOWER_BLUE.getIndex());// 设置背景色
		cell.setCellStyle(titleCellStyle);
		return cell;
	}

	private Object getValue(Map<String, Object> headMap, Object sValue) {
		int dataType = (Integer) headMap.get("dataType");
		Object value = "";
		if (dataType != IBillItem.DECIMAL && (sValue == null || sValue.equals(""))) {
			return null;
		}
		switch (dataType) {
		
		case IBillItem.INTEGER:
			if (sValue == null || sValue.equals("")) {
				value = Integer.valueOf(0);
				break;
			}
			value = Integer.valueOf(sValue.toString().replaceAll("\\.0", ""));
			break;
		case IBillItem.DECIMAL:
			if (sValue == null || sValue.equals("")) {
				value = new UFDouble(0);
				break;
			}
			value = new UFDouble(sValue.toString());
			break;
		case IBillItem.STRING:
			value = sValue;
			// 由于从excls中读取的数据如果是字符类型的输入数字，会自动在加上.0结尾
			value = value.toString().replaceAll("\\.0", "");
			break;
		case IBillItem.BOOLEAN:
			value = UFBoolean.valueOf(sValue.toString());
			break;
		case IBillItem.DATE:
			value = new UFDate(sValue.toString());
			break;
		case IBillItem.LITERALDATE:
			value = new UFLiteralDate(sValue.toString());
			break;
		case IBillItem.COMBO:
			//枚举
			value = sValue;
			String enum_id = (String) headMap.get("enum_id");
			if(StringUtils.isNotBlank(enum_id)) {
				try {
					List<EnumValueVO> enumList = this.getEnumVO(enum_id,value.toString());
					if(enumList != null && enumList.size() > 0) {
						value = enumList.get(0).getValue();
					}
				} catch (BusinessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			break;
		case IBillItem.UFREF:
			value = sValue;
			String pk_refinfo = (String) headMap.get("pk_refinfo");
			if(StringUtils.isNotBlank(pk_refinfo)) {
				try {
					List<DefdocVO> defList = this.getDefdocVO(pk_refinfo,value.toString());
					if(defList != null && defList.size() > 0) {
						value = defList.get(0).getPk_defdoc();
					}
				} catch (BusinessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
//				String sql = "select pk_defdoc from bd_defdoc where (code='"+sValue+"' or name = '"+sValue+"') and nvl(dr,0) = 0 and pk_defdoclist = (select bd_defdoclist.pk_defdoclist from bd_defdoclist where code = 'HR021_0xx')";
//				try {
//					String pk_defdoc = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());
//					value = pk_defdoc;
//				} catch (BusinessException e) {
//					e.printStackTrace();
//				}
//			}else if("tra_mode".equals(headMap.get("key"))) {
//				String sql = "select pk_defdoc from bd_defdoc where (code='"+sValue+"' or name = '"+sValue+"') and nvl(dr,0) = 0 and pk_defdoclist = (select bd_defdoclist.pk_defdoclist from bd_defdoclist where code = 'HR020_0xx')";
//				try {
//					String pk_defdoc = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());
//					value = pk_defdoc;
//				} catch (BusinessException e) {
//					e.printStackTrace();
//				}
//			}
			
			break;
		default:
			value = sValue;
		}
		
		if("psnCode".equals(headMap.get("key"))) {
			String sql = "select pk_psndoc from bd_psndoc where code='"+sValue+"'";
			String pk_psndoc = "";
			try {
				pk_psndoc = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());
			} catch (BusinessException e) {
				e.printStackTrace();
			}
			value = pk_psndoc;
		}
		
		return value;
	}
	
	public  List<DefdocVO> getDefdocVO(String pk_refinfo,String value) throws BusinessException{
		String sql = "select * from bd_defdoc where nvl(dr,0) = 0 and (code = '"+value+"' or name = '"+value+"') and pk_defdoclist = (select para1 from bd_refinfo where pk_refinfo = '"+pk_refinfo+"')";
        return (List<DefdocVO>) getIUAPQueryBS().executeQuery(sql, new BeanListProcessor(DefdocVO.class));
    }
	
	public  List<EnumValueVO> getEnumVO(String emunid,String name) throws BusinessException{
		String sql = "select * from md_enumvalue where id = '"+emunid+"' and name = '"+name+"' and nvl(dr,0) = 0";
        return (List<EnumValueVO>) getIUAPQueryBS().executeQuery(sql, new BeanListProcessor(EnumValueVO.class));
    }
	
	public static IUAPQueryBS iUapQueryBS;
	
	public static IUAPQueryBS getIUAPQueryBS() {
		if(iUapQueryBS == null) {
			iUapQueryBS = ServiceLocator.find(IUAPQueryBS.class);
		}
		return iUapQueryBS;
	}
	
	public Map<String,String> getSourceType(){
//		指定参训=0,报名参训=1,其他=2,手工添加=3 source_type
		Map<String,String> result = new HashMap();
		result.put("指定参训", "0");
		result.put("报名参训", "1");
		result.put("其他", "2");
		result.put("手工添加", "3");
		return result;
	}
	
	public Map<String,String> getTaketrmMethod(){
//		全部参训=0,部分参训=1,中途参训=2,其他=3 taketrm_method
		Map<String,String> result = new HashMap();
		result.put("全部参训", "0");
		result.put("部分参训", "1");
		result.put("中途参训", "2");
		result.put("其他", "3");
		return result;

	}
}
