package cn.hmsoft.ltc.common.util;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.log4j.Logger;

import com.zhuozhengsoft.pageoffice.zoomseal.User;

import cn.hmsoft.ltc.common.constants.LtContext;
import cn.hmsoft.ltc.model.Course;
import cn.hmsoft.ltc.model.DetailTable;
import cn.hmsoft.ltc.model.QuestionType;
import cn.hmsoft.ltc.model.Subject;
import cn.hmsoft.ltc.model.SubjectOption;
import cn.hmsoft.ltc.model.TestPaper;
import cn.hmsoft.ltc.model.Users;
import cn.hmsoft.ltc.service.iface.CourseService;
import cn.hmsoft.ltc.service.iface.QuestionTypeService;
import cn.hmsoft.ltc.service.iface.TestPaperService;
import cn.hmsoft.ltc.service.impl.CourseServiceImpl;
import cn.hmsoft.ltc.service.impl.QuestionTypeServiceImpl;
import cn.hmsoft.ltc.service.impl.TestPaperServiceImpl;
import cn.hmsoft.ltc.service.impl.UserServiceImpl;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;

/**
 * 根据题型导出word试题
 * @author zq
 *
 */
public class DocUtil {
	
	public static QuestionTypeService questionTypeService = new QuestionTypeServiceImpl();  //题型管理
	public static TestPaperService testPaperService = new TestPaperServiceImpl();  //试卷管理
	
	public static CourseService courseService = new CourseServiceImpl();  //课程
	
	private static final Logger log = Logger.getLogger(DocUtil.class);

	public static String SYS_HOME = System.getenv("LT_HOME") == null ? System.getProperty("user.dir") : System.getenv("LT_HOME");
	private static Configuration configuration = new Configuration();

	static {
		configuration.setDefaultEncoding("UTF-8");
		try {
			configuration.setDirectoryForTemplateLoading(new File(SYS_HOME + File.separator + "paperTmps"));
			//log.info(SYS_HOME + File.separator + "paperTmps");
		} catch (IOException e) {
			log.error(e);
		}
	}
	
	private DocUtil() {
	}

	private static String getReplaceStr(String obj){
		String objStr = obj.trim().replaceAll("\\?", "").replaceAll(">", "&gt;")
		.replaceAll("<", "&lt;").replaceAll("（", "(")
		.replaceAll("）", ")").replaceAll("&", "");
		return objStr;
	}
	
	/**
     * 去重
     * 
     * @param questionList
     * @return
     * @author 
     */
    private static List<Subject> removeDuplicateQuestion(List<Subject> questionList) {
        Set<Subject> set = new TreeSet<Subject>(new Comparator<Subject>() {
            public int compare(Subject a, Subject b) {
                // 字符串则按照asicc码升序排列
                return a.getQuestionTypeId().compareTo(b.getQuestionTypeId());
            }
        });
        set.addAll(questionList);
        return new ArrayList<Subject>(set);
    }
    
	/**
     * 去重
     * 
     * @param questionList
     * @return
     * @author 
     */
    private static List<Subject> soreQuestion(List<Subject> questionList) {
        Set<Subject> set = new TreeSet<Subject>(new Comparator<Subject>() {
            public int compare(Subject a, Subject b) {
                // 字符串则按照asicc码升序排列
                return a.getOrd().compareTo(b.getOrd());
            }
        });
        set.addAll(questionList);
        return new ArrayList<Subject>(set);
    }
	
	/**
	 * 组装数据库数据，对应word文档信息(试卷)
	 * @param lists
	 * @return
	 */
	public static List<Map<String, Object>> getQuesList(List<Subject> lists) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		for (int i=0; i<lists.size(); i++) {
			Subject subject = lists.get(i);
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put("typeId", subject.getQuestionTypeId());  //单项选题
			dataMap.put("correctOptionsNum", getCorrectOptionsNum(subject.getQuestionTypeId()));//题型类型。0.主观  题 1.单项选题，2.多项选择题 
			int count = subject.getOptions().size();
			//if (subject.getQuestionTypeId().intValue() == LtContext.TYPE_SINGLE_SELECT_ID) { ///单项选择题
		    if (getCorrectOptionsNum(subject.getQuestionTypeId()) == LtContext.CORRECT_OPTIONS_STATUS_ONE) { ///单项选择题
				for(int j = 0; j<count; j++) {
					int num = j + 1;
					if(subject.getOptions().get(j).getSubjectOptionContent() != null) {
						String singleSummary = subject.getOptions().get(j).getSubjectOptionContent();
						String singleSummaryStr =  getReplaceStr(singleSummary);
						dataMap.put("singleSummary" + num, singleSummaryStr);
					}else{
						dataMap.put("singleSummary" + num, "无");
					}
				}
				if(subject.getAnswer() != null) {
					dataMap.put("answer",  getReplaceStr(subject.getAnswer()));
				} else {
					dataMap.put("answer", "无");
				}
				
			} else if (getCorrectOptionsNum(subject.getQuestionTypeId()) == LtContext.CORRECT_OPTIONS_STATUS_TWO) {//多项选择
				for (int j = 0; j<count; j++) {
					int num1 = j + 1;
					if (subject.getOptions().get(j).getSubjectOptionContent() != null) {
						dataMap.put("summary" + num1,  getReplaceStr(subject.getOptions().get(j).getSubjectOptionContent()));
					} else {
						dataMap.put("summary" + num1, "无");
					}
				}
				if (subject.getAnswer() != null) {
					dataMap.put("answer",  getReplaceStr(subject.getAnswer()));
				} else {
					dataMap.put("answer", "无");
				}
			} else {
				if (subject.getAnswer() != null) {
					dataMap.put("answer",  getReplaceStr(subject.getAnswer()));
				} else {
					dataMap.put("answer", "无");
				}
			}
			
			if (subject.getRemark() != null) {
				String bodySummary = subject.getDry();
				String bodySummaryStr =  getReplaceStr(bodySummary);
				dataMap.put("bodySummary", bodySummaryStr);
			} else {
				dataMap.put("bodySummary", "该题无题干!");
			}
			if (subject.getChapter() != null) {
				String chapter = subject.getChapter().trim() + "章" + subject.getJoint() + "节" +
						subject.getDirectory() + "目" + subject.getPages() + "页";
				dataMap.put("chapter", chapter);
			} else {
				dataMap.put("chapter", "无");
			}
			
			dataMap.put("questionNo", subject.getSubjectNo().trim());
			dataMap.put("serialNumber", i+1); //试卷题目序号
			list.add(dataMap);
		}
		return list;
	}
	
	/**
	 * 获取课程的题型和分数
	 * @param listQuestion
	 * @return
	 */
	public static List<Map<String, Object>> getTypeAndScoreNo(List<Subject> listQuestion) {
		List<Subject> dataList = removeDuplicateQuestion(listQuestion);
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		QuestionType qytpe = new QuestionType();
		String questionTypeRemark = "";  //题型指导语
		for(int i=0; i<dataList.size(); i++){
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put("sortNo", dataList.get(i).getSortNo()); //题型序号
			dataMap.put("typeId", dataList.get(i).getQuestionTypeId()); //题型编码
			dataMap.put("typeName", dataList.get(i).getTypeCaption()); //题型-填空题、单选题、问答题 等等
			dataMap.put("score", dataList.get(i).getScore());  //分数
			dataMap.put("questionSum", dataList.get(i).getQuestionSum());  //小题总数
			dataMap.put("questionScores", dataList.get(i).getQuestionSum() * dataList.get(i).getScore());  //大题总分
			
			try {
				qytpe = questionTypeService.selectQuestionTypeById(dataList.get(i).getQuestionTypeId());
			} catch (SQLException e) {
				e.printStackTrace();
			}
			//单项选择、多项选择、主观题
			if(qytpe.getCorrectOptionsNum()== LtContext.CORRECT_OPTIONS_STATUS_ONE ) {
				//	|| dataList.get(i).getTypeCaption().contains("单项选择题")) {
				questionTypeRemark = qytpe.getGuideText();
				dataMap.put("remark", dataList.get(i).getRemark());  //题型指导语
			} else if(qytpe.getCorrectOptionsNum()== LtContext.CORRECT_OPTIONS_STATUS_ONE ) {
				//	|| dataList.get(i).getTypeCaption().contains("多项选择题")) {
				questionTypeRemark = qytpe.getGuideText();
			} else {
				questionTypeRemark = qytpe.getGuideText();
			}
			dataMap.put("correctOptionsNum", qytpe.getCorrectOptionsNum().toString());//题型类型。0.主观  题 1.单项选题，2.多项选择题Thank you.
			dataMap.put("remark", questionTypeRemark);  //题型指导语
			list.add(dataMap);
		}
		return list;
	}
	

	/**
	 * 获取题型类型。0.主管题 、1.单项选择题、2.多项选择题
	 * @param typeId
	 * @return
	 */
	public static Integer getCorrectOptionsNum(Integer typeId) {
		QuestionType qytpe = new QuestionType();
		Integer correctOptionsNum = 0;
		try {
			qytpe = questionTypeService.selectQuestionTypeById(typeId);
			correctOptionsNum = qytpe.getCorrectOptionsNum();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return correctOptionsNum;
	}
	
	/**
	 * 导出试卷信息(组卷成功后，导出试卷用于纸质考试)
	 * @param listQuestion  试卷数据
	 * @param paperName 试卷名称
	 * @param courseId 课程编码
	 * @param courseName 课程名称
	 * @param testPaperId 试卷编号
	 * @return
	 * @throws Exception
	 */
	public static String expQuestionGenWord(String fltTemplate, String dirPath, List<Subject> listQuestion, String courseCode, String courseName,String testPaperId) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> listType = new ArrayList<Map<String,Object>>();
		String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		String fileNameStr = testPaperId;//文件名
		String nameString = dirPath + File.separator + fileNameStr + ".doc";
		try {
			list = getQuesList(listQuestion);//每个大题对应的小题列表
			listType = getTypeAndScoreNo(listQuestion);//大题列表
			outFile = new File(nameString); // 导出文件
			t = configuration.getTemplate(fltTemplate);// 获取模板文件
			mybatisMap.put("columnsType", listType); //题型和分数列表
			mybatisMap.put("code", courseCode);//课程编码
			mybatisMap.put("name", courseName);//课程姓名
			mybatisMap.put("paperAB", paperAB);//获取试卷是A卷还是B卷
			mybatisMap.put("bigQs", listType.size());//大题数
			mybatisMap.put("smallQs", listQuestion.size());//小题数
			mybatisMap.put("columns", list);   //题干信息
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
		
		return nameString;
	}
	
	/**
	 * 导出试卷头部(组卷成功后，导出试卷用于纸质考试)
	 * @param listQuestion  试卷数据
	 * @param paperName 试卷名称
	 * @param courseId 课程编码
	 * @param courseName 课程名称
	 * @param testPaperId 试卷编号
	 * @return
	 * @throws Exception
	 */
	private static String genWordHeader(String fltTemplate, String dirPath, int bigQs, int smQs, String courseCode, String courseName, String testPaperId) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		String nameString = dirPath;
		try {
			outFile = new File(nameString); // 导出文件
			t = configuration.getTemplate(fltTemplate);// 获取模板文件
			mybatisMap.put("courseCode", courseCode);//课程编码
			mybatisMap.put("courseName", courseName);//课程姓名
			mybatisMap.put("AB", paperAB);//获取试卷是A卷还是B卷
			mybatisMap.put("bigQs", bigQs);//大题数
			mybatisMap.put("smQs", smQs);//小题数
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
		
		return nameString;
	}
	
	/**
	 * 构建大题.
	 * @param fltTemplate
	 * @param dirPath
	 * @param quesNums
	 * @param score
	 * @param scoreTotal
	 * @param qsGuideText
	 */
	private static void genBigQs(String fltTemplate, String dirPath, Integer quesNums, String score, String scoreTotal, String bigCaption, String qsGuideText) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		try {
			outFile = new File(dirPath); // 导出文件
			t = configuration.getTemplate(fltTemplate);// 获取模板文件
			mybatisMap.put("quesNums", quesNums);//大题对应的小题数
			mybatisMap.put("score", score);//小题分
			mybatisMap.put("scoreTotal", scoreTotal);//大题总分
			mybatisMap.put("bigCaption", bigCaption);//大题名
			mybatisMap.put("qsGuideText", qsGuideText);//大题指导语
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
	}
	
	//构建试卷头word
	public static void genPaperHeaderWord(String fltTemplate, String docxPath, int bigQs, int smQs, String courseCode, String courseName, String testPaperId) {
		String basePath = System.getProperty("user.dir") + File.separator + "resources" + File.separator + "word-factory" + File.separator + "header";
		String xmlPath = basePath + File.separator + "word" + File.separator + "document.xml";
		genWordHeader(fltTemplate, xmlPath, bigQs, smQs, courseCode, courseName, testPaperId);//生成 填充后的xml文件,覆盖到 xmlPath
    	File dir = new File(basePath);
    	ZipHelper.compress(Arrays.asList(dir.listFiles()), new File(docxPath));
	}
	
	//构建答案头word
	public static void genAsHeaderWord(String fltTemplate, String docxPath, int bigQs, int smQs, String courseCode, String courseName, String testPaperId) {
		String basePath = System.getProperty("user.dir") + File.separator + "resources" + File.separator + "word-factory" + File.separator + "asHeader";
		String xmlPath = basePath + File.separator + "word" + File.separator + "document.xml";
		genWordHeader(fltTemplate, xmlPath, bigQs, smQs, courseCode, courseName, testPaperId);//生成 填充后的xml文件,覆盖到 xmlPath
    	File dir = new File(basePath);
    	ZipHelper.compress(Arrays.asList(dir.listFiles()), new File(docxPath));
	}
	
	//构建大题 题干描述
	public static void genBigQsWord(String fltTemplate, String docxPath, Integer quesNums, String score, String scoreTotal, String bigCaption, String qsGuideText) {
		String basePath = System.getProperty("user.dir") + File.separator + "resources" + File.separator + "word-factory" + File.separator + "bigQus";
		String xmlPath = basePath + File.separator + "word" + File.separator + "document.xml";
		genBigQs(fltTemplate, xmlPath, quesNums, score, scoreTotal, bigCaption, qsGuideText);//生成 填充后的xml文件,覆盖到 xmlPath
    	File dir = new File(basePath);
    	ZipHelper.compress(Arrays.asList(dir.listFiles()), new File(docxPath));
	}
	
	//构建单选word
	public static void genSmSingleSelect(String fltTemplate, String docxPath, String qsNo) {
		String basePath = System.getProperty("user.dir") + File.separator + "resources" + File.separator + "word-factory" + File.separator + "smSingleSelect";
		String xmlPath = basePath + File.separator + "word" + File.separator + "document.xml";
		genSmQs(fltTemplate, xmlPath, qsNo);//生成 填充后的xml文件,覆盖到 xmlPath 
    	File dir = new File(basePath);
    	ZipHelper.compress(Arrays.asList(dir.listFiles()), new File(docxPath));
	}
	
	//构建多选word
	public static void genSmMultiSelect(String fltTemplate, String docxPath, String qsNo) {
		String basePath = System.getProperty("user.dir") + File.separator + "resources" + File.separator + "word-factory" + File.separator + "smMultiSelect";
		String xmlPath = basePath + File.separator + "word" + File.separator + "document.xml";
		genSmQs(fltTemplate, xmlPath, qsNo);//生成 填充后的xml文件,覆盖到 xmlPath 
    	File dir = new File(basePath);
    	ZipHelper.compress(Arrays.asList(dir.listFiles()), new File(docxPath));
	}
	
	//构建其他题型word
	public static void genSmOther(String fltTemplate, String docxPath, String qsNo) {
		String basePath = System.getProperty("user.dir") + File.separator + "resources" + File.separator + "word-factory" + File.separator + "smQsOther";
		String xmlPath = basePath + File.separator + "word" + File.separator + "document.xml";
		genSmQs(fltTemplate, xmlPath, qsNo);//生成 填充后的xml文件,覆盖到 xmlPath 
    	File dir = new File(basePath);
    	ZipHelper.compress(Arrays.asList(dir.listFiles()), new File(docxPath));
	}
	
	/**
	 * 构建大题中的小题(单选、多选、其他题型 都只生成一个题目号-公用此方法).
	 * @param qsNo 题目试卷中的编号
	 */
	private static void genSmQs(String fltTemplate, String xmlPath, String qsNo) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		try {
			outFile = new File(xmlPath); // 导出文件
			t = configuration.getTemplate(fltTemplate);// 获取模板文件
			mybatisMap.put("qsNo", qsNo);//题目试卷中的编号
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
	}
	
	/**
	 * 导出试卷信息(组卷成功后，导出试卷答案用于纸质考试)
	 * @param dirPath 路径
	 * @param listQuestion  试卷数据
	 * @param courseCode 课程编码
	 * @param courseName 课程名称
	 * @param testPaperId 试卷编号
	 * @return
	 * @throws Exception
	 */
	public static String expAnswerGenWord(String dirPath, List<Subject> listQuestion, String courseCode, String courseName,String testPaperId) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> listType = new ArrayList<Map<String,Object>>();
		String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		String fileNameStr = testPaperId;//文件名
		String nameString = dirPath + File.separator + fileNameStr + "N.doc";
		try {
		
			list = getQuesList(listQuestion);
			listType = getTypeAndScoreNo(listQuestion);
			outFile = new File(nameString); // 导出文件
			//t = configuration.getTemplate("paperAnswer1.ftl"); // 获取模板文件
			t = configuration.getTemplate("paperAnswer.ftl"); // 获取模板文件
			mybatisMap.put("columnsType", listType); //题型和分数
			
			mybatisMap.put("code", courseCode);//课程编码
			mybatisMap.put("name", courseName);//课程名称
			mybatisMap.put("paperAB", paperAB);//获取试卷是A卷还是B卷
			mybatisMap.put("columns", list);  //提供信息
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
		
		return nameString;
	}
	
	//转印答题卡导出
	public static String expPrintCard(String dirPath, String courseCode, String courseName, String testPaperId, 
			String printCardType) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		String nameString = dirPath + File.separator + testPaperId + "卷-答题卡制作说明.doc";
		try {
			outFile = new File(nameString); // 导出文件
			t = configuration.getTemplate("printCard.ftl"); // 获取模板文件
			mybatisMap.put("paperNo", testPaperId); //题型和分数
			mybatisMap.put("courseCode", courseCode);//课程编码
			mybatisMap.put("courseName", courseName);//课程姓
			mybatisMap.put("printCardType", printCardType);
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
		
		return nameString;
	}
	
	/**
	 * 命题纸封面 导出
	 * @param dirPath  路径
	 * @param courseCode   课程编号
	 * @param courseName   课程名称
	 * @param testPaperId  试卷编号
	 * @param user 用户信息
	 * @return
	 * @throws SQLException 
	 */
	public static String expQuestionGenWordCover(String dirPath, String courseCode, String courseName, String testPaperId,Users user) throws SQLException {
			Map<String, Object> mybatisMap = new HashMap<String, Object>();
			String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
			File outFile = null;//导出文件
			Writer out = null;
			Template t = null;
			String nameString = dirPath + File.separator + testPaperId + "命题纸封面.doc";
			Course course = courseService.selectCourseById(user.getCourseId());
			try {
				outFile = new File(nameString); // 导出文件
				t = configuration.getTemplate("paperCover.ftl"); // 获取模板文件
				mybatisMap.put("paperNo", testPaperId); //试卷编号、计算机编号
				mybatisMap.put("paperAB", paperAB);//获取试卷是A卷还是B卷
				mybatisMap.put("courseCode", courseCode);//课程编码
				mybatisMap.put("courseName", courseName);//课程名称
				mybatisMap.put("teachBookName", user.getTeachBook());//教材名称
				
				mybatisMap.put("editor", course.getEditor());//【编者】
				mybatisMap.put("edition", course.getEdition());//【版次】
				mybatisMap.put("press", course.getPress());//【出版社】
				
				mybatisMap.put("userName", user.getTeacherName());//命题人姓名
				mybatisMap.put("paperDate", DateUtil.stringFormat(user.getCreateDate()));//命题时间
				mybatisMap.put("schoolName", user.getSchoolName());//命题单位
				mybatisMap.put("userPhone", user.getPhone());//联系人电话
				mybatisMap.put("titleName", user.getTitleName());//命题职称
				
				out = new BufferedWriter(new OutputStreamWriter(
						new FileOutputStream(outFile), "UTF-8"));
				t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
			} catch (FileNotFoundException e1) {
				log.error(e1);
			} catch (TemplateException e) {
				log.error(e);
			} catch (IOException ee) {
				log.error(ee);
			} finally {
				try {
					out.flush();
				} catch (IOException e) {
					log.error(e);
				}
				try {
					out.close();
				} catch (IOException e) {
					log.error(e);
				}
			}
			
			return nameString;
		}
	
	/**
	 * 答题纸封面 导出
	 * @param dirPath  路径
	 * @param courseCode   课程编号
	 * @param courseName   课程名称
	 * @param testPaperId  试卷编号
	 * @param user 用户信息
	 * @return
	 */
	public static String expAnswerGenCover(String dirPath, String courseCode, String courseName, String testPaperId,Users user) {
				Map<String, Object> mybatisMap = new HashMap<String, Object>();
				String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
				File outFile = null;//导出文件
				Writer out = null;
				Template t = null;
				String nameString = dirPath + testPaperId + "N答案纸封面.doc";
				try {
					outFile = new File(nameString); // 导出文件
					t = configuration.getTemplate("answerCover.ftl"); // 获取模板文件
					mybatisMap.put("paperNo", testPaperId+"N"); //试卷编号、计算机编号
					mybatisMap.put("paperAB", paperAB);//获取试卷是A卷还是B卷
					mybatisMap.put("courseCode", courseCode);//课程编码
					mybatisMap.put("courseName", courseName);//课程名称
					mybatisMap.put("teachBookName", user.getTeachBook());//教材名称
					mybatisMap.put("userName", user.getTeacherName());//命题人姓名
					mybatisMap.put("paperDate", DateHelper.formatToChina(LocalDate.now()));//命题时间
					mybatisMap.put("schoolName", user.getSchoolName());//命题单位
					mybatisMap.put("userPhone", user.getPhone());//联系人电话
					mybatisMap.put("titleName", user.getTitleName());//命题职称
					
					out = new BufferedWriter(new OutputStreamWriter(
							new FileOutputStream(outFile), "UTF-8"));
					t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
				} catch (FileNotFoundException e1) {
					log.error(e1);
				} catch (TemplateException e) {
					log.error(e);
				} catch (IOException ee) {
					log.error(ee);
				} finally {
					try {
						out.flush();
					} catch (IOException e) {
						log.error(e);
					}
					try {
						out.close();
					} catch (IOException e) {
						log.error(e);
					}
				}
				
				return nameString;
			}
	
	
	/**
	 *  试卷页面信息
	 * @param lists
	 * @return
	 */
	public static List<Map<String, Object>> getQuesPaperPageList(List<Subject> lists) {
		List<Subject> listData = soreQuestion(lists);
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		for (int i=0; i<listData.size(); i++) {
			Subject subject = listData.get(i);
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put("typeId", subject.getQuestionTypeId());  //单项选题
			dataMap.put("correctOptionsNum", getCorrectOptionsNum(subject.getQuestionTypeId()));//题型类型。0.主观  题 1.单项选题，2.多项选择题 
			int count = subject.getOptions().size();
			//if (subject.getQuestionTypeId().intValue() == LtContext.TYPE_SINGLE_SELECT_ID) { ///单项选择题
		    if (getCorrectOptionsNum(subject.getQuestionTypeId()) == LtContext.CORRECT_OPTIONS_STATUS_ONE) { ///单项选择题
				for(int j = 0; j<count; j++) {
					int num = j + 1;
					if(subject.getOptions().get(j).getSubjectOptionContent() != null) {
						String singleSummary = subject.getOptions().get(j).getSubjectOptionContent();
						String singleSummaryStr =  getReplaceStr(singleSummary);
						dataMap.put("singleSummary" + num, singleSummaryStr);
					}else{
						dataMap.put("singleSummary" + num, "无");
					}
				}
				if(subject.getAnswer() != null) {
					dataMap.put("answer",  getReplaceStr(subject.getAnswer()));
				} else {
					dataMap.put("answer", "无");
				}
				
			} else if (getCorrectOptionsNum(subject.getQuestionTypeId()) == LtContext.CORRECT_OPTIONS_STATUS_TWO) {//多项选择
				for (int j = 0; j<count; j++) {
					int num1 = j + 1;
					if (subject.getOptions().get(j).getSubjectOptionContent() != null) {
						dataMap.put("summary" + num1,  getReplaceStr(subject.getOptions().get(j).getSubjectOptionContent()));
					} else {
						dataMap.put("summary" + num1, "无");
					}
				}
				if (subject.getAnswer() != null) {
					dataMap.put("answer",  getReplaceStr(subject.getAnswer()));
				} else {
					dataMap.put("answer", "无");
				}
			} else {
				if (subject.getAnswer() != null) {
					dataMap.put("answer",  getReplaceStr(subject.getAnswer()));
				} else {
					dataMap.put("answer", "无");
				}
			}
			
			if (subject.getRemark() != null) {
				String bodySummary = subject.getDry();
				String bodySummaryStr =  getReplaceStr(bodySummary);
				dataMap.put("bodySummary", bodySummaryStr);
			} else {
				dataMap.put("bodySummary", "该题无题干!");
			}
			if (subject.getChapter() != null) {
				String chapter = subject.getChapter().trim() + "章" + subject.getJoint() + "节" +
						subject.getDirectory() + "目" + subject.getPages() + "页" + "    "+subject.getRemark();
				dataMap.put("chapter", chapter);
			} else {
				dataMap.put("chapter", "无");
			}
			
			//dataMap.put("questionNo", subject.getSubjectNo().trim());
			//dataMap.put("serialNumber", i+1); //试卷题目序号
			dataMap.put("serialNumber", subject.getOrd()); //试卷题目序号
			list.add(dataMap);
		}
		return list;
	}
	
	/**
	 * 导出试卷页码信息
	 * @param dirPath 路径
	 * @param listQuestion  试卷数据
	 * @param courseCode 课程编码
	 * @param courseName 课程名称
	 * @param testPaperId 试卷编号
	 * @return
	 * @throws Exception
	 */
	public static String expPaperPage(String dirPath, List<Subject> listQuestion, String courseCode, String courseName,String testPaperId) {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> listType = new ArrayList<Map<String,Object>>();
		String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
		File outFile = null;//导出文件
		Writer out = null;
		Template t = null;
		String fileNameStr = testPaperId;//文件名
		String nameString = dirPath + File.separator + fileNameStr + "-题目页码.doc";
		try {
		
			list = getQuesPaperPageList(listQuestion);
			//listType = getTypeAndScoreNo(listQuestion);
			outFile = new File(nameString); // 导出文件
			//t = configuration.getTemplate("paperAnswer1.ftl"); // 获取模板文件
			t = configuration.getTemplate("paperPage.ftl"); // 获取模板文件
			//mybatisMap.put("columnsType", listType); //题型和分数
			
			mybatisMap.put("code", courseCode);//课程编码
			mybatisMap.put("name", courseName);//课程名称
			mybatisMap.put("paperAB", paperAB);//获取试卷是A卷还是B卷
			mybatisMap.put("columns", list);  //提供信息
			out = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}
		
		return nameString;
	}
	
	/**
	 * 自考省级命题自审项目表 导出
	 * @param dirPath  路径
	 * @param testPaperId  试卷编号
	 * @param user 用户信息
	 * @return
	 */
	public static String expSelfAuditItemList(String dirPath, String testPaperId,Users user) {
				Map<String, Object> mybatisMap = new HashMap<String, Object>();
				String paperAB = testPaperId.substring(testPaperId.length()-1,testPaperId.length()); //获取试卷是A卷还是B卷
				File outFile = null;//导出文件
				Writer out = null;
				Template t = null;
				String nameString = dirPath + testPaperId + "-自考省级征集命题自审项目表.doc";
				try {
					outFile = new File(nameString); // 导出文件
					t = configuration.getTemplate("selfAuditItemList.ftl"); // 获取模板文件
					mybatisMap.put("paperNo", testPaperId); //试卷编号、计算机编号
					mybatisMap.put("paperAB", paperAB);//获取试卷是A卷还是B卷					
					out = new BufferedWriter(new OutputStreamWriter(
							new FileOutputStream(outFile), "UTF-8"));
					t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
				} catch (FileNotFoundException e1) {
					log.error(e1);
				} catch (TemplateException e) {
					log.error(e);
				} catch (IOException ee) {
					log.error(ee);
				} finally {
					try {
						out.flush();
					} catch (IOException e) {
						log.error(e);
					}
					try {
						out.close();
					} catch (IOException e) {
						log.error(e);
					}
				}
				
				return nameString;
			}
	
	
	/**
	 * 细目表导出word 导出
	 * 
	 * @param dirPath     路径
	 * @param courseCode  课程编号
	 * @param courseName  课程名称
	 * @param testPaperId 试卷编号
	 * @param user        用户信息
	 * @param tableList   细目比表信息
	 * @return
	 * @throws SQLException 
	 */
	public static String expPaperDetailTable(String dirPath, String courseCode, String courseName, String testPaperId,
			Users user,List<DetailTable> tableList) throws SQLException {
		Map<String, Object> mybatisMap = new HashMap<String, Object>();
		String paperAB = testPaperId.substring(testPaperId.length() - 1, testPaperId.length()); // 获取试卷是A卷还是B卷
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		File outFile = null;// 导出文件
		Writer out = null;
		Template t = null;
		Course course = courseService.selectCourseById(user.getCourseId());
		String nameString = dirPath + testPaperId + "试卷结构细目表.doc";
		try {
			list = getDetailTableAndScore(tableList);
			Integer totalQuestionSum = 0;
			for(int i=0;i<tableList.size();i++) {
				totalQuestionSum += tableList.get(i).getTx0Nums()+tableList.get(i).getTx1Nums()+tableList.get(i).getTx2Nums()
						+tableList.get(i).getTx3Nums()+tableList.get(i).getTx4Nums()+tableList.get(i).getTx5Nums()
						+tableList.get(i).getTx6Nums()+tableList.get(i).getTx7Nums()+tableList.get(i).getTx8Nums()
						+tableList.get(i).getTx9Nums()+tableList.get(i).getTx10Nums()+tableList.get(i).getTx11Nums()
						+tableList.get(i).getTx12Nums()+tableList.get(i).getTx13Nums()+tableList.get(i).getTx14Nums()
						+tableList.get(i).getTx15Nums()+tableList.get(i).getTx16Nums()+tableList.get(i).getTx17Nums()
						+tableList.get(i).getTx18Nums()+tableList.get(i).getTx19Nums()+tableList.get(i).getTx20Nums()
						+tableList.get(i).getTx21Nums()+tableList.get(i).getTx22Nums()+tableList.get(i).getTx23Nums()
						+tableList.get(i).getTx24Nums()+tableList.get(i).getTx25Nums();//小题总题量
			}
			outFile = new File(nameString); // 导出文件
			t = configuration.getTemplate("paperDetailTable.ftl"); // 获取模板文件
			mybatisMap.put("paperNo", testPaperId); // 试卷编号、计算机编号
			mybatisMap.put("paperAB", paperAB);// 获取试卷是A卷还是B卷
			mybatisMap.put("courseCode", courseCode);// 课程编码
			mybatisMap.put("courseName", courseName);// 课程名称
			mybatisMap.put("userName", user.getTeacherName());// 命题人姓名
			mybatisMap.put("totalQuestionSum", totalQuestionSum);// 该课程的汇总题量
			mybatisMap.put("columns", list);  //提供信息
			

			mybatisMap.put("totalQuestionSum0", getTotalQuestionSum0(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum1", getTotalQuestionSum1(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum2", getTotalQuestionSum2(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum3", getTotalQuestionSum3(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum4", getTotalQuestionSum4(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum5", getTotalQuestionSum5(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum6", getTotalQuestionSum6(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum7", getTotalQuestionSum7(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum8", getTotalQuestionSum8(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum9", getTotalQuestionSum9(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum10", getTotalQuestionSum10(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum11", getTotalQuestionSum11(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum12", getTotalQuestionSum12(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum13", getTotalQuestionSum13(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum14", getTotalQuestionSum14(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum15", getTotalQuestionSum15(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum16", getTotalQuestionSum16(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum17", getTotalQuestionSum17(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum18", getTotalQuestionSum18(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum19", getTotalQuestionSum19(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum20", getTotalQuestionSum20(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum21", getTotalQuestionSum21(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum22", getTotalQuestionSum22(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum23", getTotalQuestionSum23(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum24", getTotalQuestionSum24(tableList));  //章节题量汇总
			mybatisMap.put("totalQuestionSum25", getTotalQuestionSum25(tableList));  //章节题量汇总
			
			mybatisMap.put("itemScoreSum0", getItemScoreSum0(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum1", getItemScoreSum1(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum2", getItemScoreSum2(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum3", getItemScoreSum3(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum4", getItemScoreSum4(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum5", getItemScoreSum5(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum6", getItemScoreSum6(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum7", getItemScoreSum7(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum8", getItemScoreSum8(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum9", getItemScoreSum9(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum10", getItemScoreSum10(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum11", getItemScoreSum11(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum12", getItemScoreSum12(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum13", getItemScoreSum13(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum14", getItemScoreSum14(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum15", getItemScoreSum15(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum16", getItemScoreSum16(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum17", getItemScoreSum17(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum18", getItemScoreSum18(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum19", getItemScoreSum19(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum20", getItemScoreSum20(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum21", getItemScoreSum21(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum22", getItemScoreSum22(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum23", getItemScoreSum23(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum24", getItemScoreSum24(tableList));  //章节小题分汇总
			mybatisMap.put("itemScoreSum25", getItemScoreSum25(tableList));  //章节小题分汇总
			
			mybatisMap.put("keyChaptersStatus0", getKeyChaptersStatus0(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus1", getKeyChaptersStatus1(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus2", getKeyChaptersStatus2(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus3", getKeyChaptersStatus3(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus4", getKeyChaptersStatus4(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus5", getKeyChaptersStatus5(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus6", getKeyChaptersStatus6(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus7", getKeyChaptersStatus7(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus8", getKeyChaptersStatus8(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus9", getKeyChaptersStatus9(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus10", getKeyChaptersStatus10(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus11", getKeyChaptersStatus11(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus12", getKeyChaptersStatus12(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus13", getKeyChaptersStatus13(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus14", getKeyChaptersStatus14(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus15", getKeyChaptersStatus15(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus16", getKeyChaptersStatus16(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus17", getKeyChaptersStatus17(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus18", getKeyChaptersStatus18(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus19", getKeyChaptersStatus19(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus20", getKeyChaptersStatus20(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus21", getKeyChaptersStatus21(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus22", getKeyChaptersStatus22(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus23", getKeyChaptersStatus23(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus24", getKeyChaptersStatus24(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节
			mybatisMap.put("keyChaptersStatus25", getKeyChaptersStatus25(testPaperId));  //重点章节状态 0：非重点章节   1：重点章节

			mybatisMap.put("flagStatus0", getFlagStatus0(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus1", getFlagStatus1(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus2", getFlagStatus2(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus3", getFlagStatus3(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus4", getFlagStatus4(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus5", getFlagStatus5(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus6", getFlagStatus6(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus7", getFlagStatus7(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus8", getFlagStatus8(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus9", getFlagStatus9(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus10", getFlagStatus10(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus11", getFlagStatus11(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus12", getFlagStatus12(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus13", getFlagStatus13(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus14", getFlagStatus14(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus15", getFlagStatus15(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus16", getFlagStatus16(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus17", getFlagStatus17(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus18", getFlagStatus18(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus19", getFlagStatus19(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus20", getFlagStatus20(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus21", getFlagStatus21(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus22", getFlagStatus22(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus23", getFlagStatus23(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus24", getFlagStatus24(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示
			mybatisMap.put("flagStatus25", getFlagStatus25(course.getChapterNumber()));  //根据章节数显示对应的章节题量 0：不显示   1：显示

			
			out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"));
			t.process(mybatisMap, out); // 将填充数据填入模板文件并输出到目标文件
		} catch (FileNotFoundException e1) {
			log.error(e1);
		} catch (TemplateException e) {
			log.error(e);
		} catch (IOException ee) {
			log.error(ee);
		} finally {
			try {
				out.flush();
			} catch (IOException e) {
				log.error(e);
			}
			try {
				out.close();
			} catch (IOException e) {
				log.error(e);
			}
		}

		return nameString;
	}
	
	/**
     * 去重
     * 
     * @param questionList
     * @return
     * @author 
     */
    private static List<DetailTable> removeDuplicateTableDetail(List<DetailTable> tableList) {
        Set<DetailTable> set = new TreeSet<DetailTable>(new Comparator<DetailTable>() {
            public int compare(DetailTable a, DetailTable b) {
                // 字符串则按照asicc码升序排列
                return a.getQuestionTypeId().compareTo(b.getQuestionTypeId());
            }
        });
        set.addAll(tableList);
        return new ArrayList<DetailTable>(set);
    }
	
	/**
	 * 获取细目表章节及分数汇总
	 * @param listQuestion
	 * @return
	 */
	public static List<Map<String, Object>> getDetailTableAndScore(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		QuestionType qytpe = new QuestionType();
		for(int i=0; i<dataList.size(); i++){
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put("tx0Nums", dataList.get(i).getTx0Nums()); //序论  0
			dataMap.put("tx1Nums", dataList.get(i).getTx1Nums()); // 章节
			dataMap.put("tx2Nums", dataList.get(i).getTx2Nums()); // 章节
			dataMap.put("tx3Nums", dataList.get(i).getTx3Nums()); // 章节
			dataMap.put("tx4Nums", dataList.get(i).getTx4Nums()); // 章节
			dataMap.put("tx5Nums", dataList.get(i).getTx5Nums()); // 章节
			dataMap.put("tx6Nums", dataList.get(i).getTx6Nums()); // 章节
			dataMap.put("tx7Nums", dataList.get(i).getTx7Nums()); // 章节
			dataMap.put("tx8Nums", dataList.get(i).getTx8Nums()); // 章节
			dataMap.put("tx9Nums", dataList.get(i).getTx9Nums()); // 章节
			dataMap.put("tx10Nums", dataList.get(i).getTx10Nums()); // 章节
			dataMap.put("tx11Nums", dataList.get(i).getTx11Nums()); // 章节
			dataMap.put("tx12Nums", dataList.get(i).getTx12Nums()); // 章节
			dataMap.put("tx13Nums", dataList.get(i).getTx13Nums()); // 章节
			dataMap.put("tx14Nums", dataList.get(i).getTx14Nums()); // 章节
			dataMap.put("tx15Nums", dataList.get(i).getTx15Nums()); // 章节
			dataMap.put("tx16Nums", dataList.get(i).getTx16Nums()); // 章节
			dataMap.put("tx17Nums", dataList.get(i).getTx17Nums()); // 章节
			dataMap.put("tx18Nums", dataList.get(i).getTx18Nums()); // 章节
			dataMap.put("tx19Nums", dataList.get(i).getTx19Nums()); // 章节
			dataMap.put("tx20Nums", dataList.get(i).getTx20Nums()); // 章节
			dataMap.put("tx21Nums", dataList.get(i).getTx21Nums()); // 章节
			dataMap.put("tx22Nums", dataList.get(i).getTx22Nums()); // 章节
			dataMap.put("tx23Nums", dataList.get(i).getTx23Nums()); // 章节
			dataMap.put("tx24Nums", dataList.get(i).getTx24Nums()); // 章节
			dataMap.put("tx25Nums", dataList.get(i).getTx25Nums()); // 章节
			dataMap.put("itemScore", dataList.get(i).getItemScore());  //小题分
			Integer questionSum = dataList.get(i).getTx0Nums()+dataList.get(i).getTx1Nums()+dataList.get(i).getTx2Nums()
					+dataList.get(i).getTx3Nums()+dataList.get(i).getTx4Nums()+dataList.get(i).getTx5Nums()
					+dataList.get(i).getTx6Nums()+dataList.get(i).getTx7Nums()+dataList.get(i).getTx8Nums()
					+dataList.get(i).getTx9Nums()+dataList.get(i).getTx10Nums()+dataList.get(i).getTx11Nums()
					+dataList.get(i).getTx12Nums()+dataList.get(i).getTx13Nums()+dataList.get(i).getTx14Nums()
					+dataList.get(i).getTx15Nums()+dataList.get(i).getTx16Nums()+dataList.get(i).getTx17Nums()
					+dataList.get(i).getTx18Nums()+dataList.get(i).getTx19Nums()+dataList.get(i).getTx20Nums()
					+dataList.get(i).getTx21Nums()+dataList.get(i).getTx22Nums()+dataList.get(i).getTx23Nums()
					+dataList.get(i).getTx24Nums()+dataList.get(i).getTx25Nums();//小题总题量
			try {
				qytpe = questionTypeService.selectQuestionTypeById(dataList.get(i).getQuestionTypeId());
			} catch (SQLException e) {
				e.printStackTrace();
			}
			dataMap.put("typeName", qytpe.getName()); //题型名
			dataMap.put("questionSum", questionSum);  //小题总题量
			dataMap.put("questionScores", questionSum * dataList.get(i).getItemScore());  //大题总分
			list.add(dataMap);
		}
		return list;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum0(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx0Nums(); //序论  0	
		}
		return totalQuestionSum;
	}
	
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum1(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx1Nums(); //章节题量汇总 	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum2(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx2Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum3(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx3Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum4(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx4Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum5(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx5Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum6(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx6Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum7(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx7Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum8(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx8Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum9(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx9Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum10(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx10Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum11(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx11Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum12(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx12Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum13(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx13Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum14(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx14Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum15(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx15Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum16(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx16Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum17(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx17Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum18(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx18Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum19(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx19Nums(); //章节题量汇总	
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum20(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx20Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum21(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx21Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum22(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx22Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum23(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx23Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum24(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx24Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	
	/**
	 * 获取细目表章节题量汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getTotalQuestionSum25(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer totalQuestionSum = 0;
		for(int i=0; i<dataList.size(); i++){
			totalQuestionSum += dataList.get(i).getTx25Nums(); //章节题量汇总
		}
		return totalQuestionSum;
	}
	

	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum0(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx0Nums() * dataList.get(i).getItemScore()); //序论  章节小题分汇总	
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum1(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx1Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum2(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx2Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum3(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx3Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum4(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx4Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum5(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx5Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum6(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx6Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum7(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx7Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum8(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx8Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum9(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx9Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum10(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx10Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum11(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx11Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum12(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx12Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum13(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx13Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum14(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx14Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum15(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx15Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum16(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx16Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum17(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx17Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum18(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx18Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum19(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx19Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum20(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx20Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum21(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx21Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum22(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx22Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum23(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx23Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum24(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx24Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 * 获取细目表章节小题分汇总
	 * @param tableList
	 * @return
	 */
	public static Integer getItemScoreSum25(List<DetailTable> tableList) {
		List<DetailTable> dataList = removeDuplicateTableDetail(tableList);
		Integer itemScoreSum = 0;
		for(int i=0; i<dataList.size(); i++){
			Integer scoreSum = (int) (dataList.get(i).getTx25Nums() * dataList.get(i).getItemScore()); //章节小题分汇总
			itemScoreSum += scoreSum;
		}
		return itemScoreSum;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus0(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==0) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus1(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==1) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus2(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==2) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus3(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==3) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus4(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==4) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus5(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==5) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus6(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==6) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus7(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==7) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus8(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==8) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus9(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==9) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus10(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==10) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus11(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==11) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus12(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==12) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus13(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==13) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus14(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==14) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus15(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==15) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus16(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==16) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus17(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==17) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus18(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==18) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus19(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==19) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus20(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==20) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus21(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==21) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus22(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==22) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus23(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==23) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus24(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==24) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	/**
	 *  获取  重点章节状态 0：非重点章节   1：重点章节
	 * @param testPaperId   试卷编号
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getKeyChaptersStatus25(String testPaperId) throws SQLException {
		Integer keyChaptersStatus = 0;
		TestPaper testPaper = testPaperService.selectTestPaperByPageNo(testPaperId);
		String chapters = testPaper.getKeyChapters();
		if(!chapters.equals("")) {
			Integer count = search(chapters,","); //获取字符串中的重复数据
			String[] str = chapters.split(","); //获取字符串单个信息
			for(int i=0;i<=count;i++) {
				Integer num = Integer.valueOf(str[i]);
				if(num==25) {
					keyChaptersStatus = 1;
				}
			}
		}
		return keyChaptersStatus;
	}
	
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus0(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 0;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus1(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 1;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus2(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 2;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus3(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 3;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus4(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 4;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus5(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 5;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus6(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 6;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus7(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 7;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus8(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 8;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus9(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 9;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus10(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 10;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus11(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 11;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus12(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 12;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus13(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 13;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus14(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 14;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus15(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 15;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus16(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 16;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus17(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 17;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus18(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 18;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus19(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 19;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus20(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 20;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus21(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 21;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus22(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 22;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus23(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 23;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus24(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 24;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 *  根据章节数显示对应的章节题量 0：不显示   1：显示
	 * @param  chapterNumber 课程章节数量
	 * @return
	 * @throws SQLException 
	 */
	public static Integer getFlagStatus25(Integer chapterNumber) throws SQLException {
		Integer flagStatus = 1;
		int i = 25;
		if (i > chapterNumber) {
			flagStatus = 0;
		}
		return flagStatus;
	}
	
	/**
	 * 查找字符串里与指定字符串相同的个数
	 * @param str  字符串
	 * @param strRes  重复字符串
	 * @return
	 */
	public static int search(String str,String strRes) {
        int n=0;//计数器
        while(str.indexOf(strRes)!=-1) {
            int i = str.indexOf(strRes);
            n++;
            str = str.substring(i+1);
        }
        return n;
    }
	
	private static List<Subject> getQuestionList() {
		List<Subject> list = new ArrayList<Subject>();
		//一、单选题
		Subject q1 = buildSingleSelect(1, 1, 117, 3, 10.0, "单项选择题", "我国资本项目分类开放战略中属于严格控制类的是",
				"在每小题列出的四个备选项中只有一个是符合题目要求的，请用鼠标勾选出正确的选项。错选、多选或未选均无分。");
		Subject q2 = buildSingleSelect(2, 1, 117, 3, 10.0, "单项选择题", "某年世界出口贸易额为3.2万亿美元，进口贸易额为3.3万亿美元，该年国际贸易额为",
				"在每小题列出的四个备选项中只有一个是符合题目要求的，请用鼠标勾选出正确的选项。错选、多选或未选均无分。");
		Subject q3 = buildSingleSelect(3, 1, 117, 3, 10.0, "单项选择题", "下列关于国际收支平衡表记账方法正确的说法是",
				"在每小题列出的四个备选项中只有一个是符合题目要求的，请用鼠标勾选出正确的选项。错选、多选或未选均无分。");
		//二、多选题
		Subject q4 = buildMultiySelect(4, 2, 118, 3, 5.0, "多项选择题", "国际工程承包保险的险别有", 
				"在每小题列出的四个备选项中只有一个是符合题目要求的，请用鼠标勾选出正确的选项。错选、多选或未选均无分。");
		Subject q5 = buildMultiySelect(5, 2, 118, 3, 5.0, "多项选择题", "中国全面加入WTO后，中、外资银行竞争的焦点集中在", 
				"在每小题列出的四个备选项中只有一个是符合题目要求的，请用鼠标勾选出正确的选项。错选、多选或未选均无分。");
		Subject q6 = buildMultiySelect(6, 2, 118, 3, 5.0, "多项选择题", "以下关于发明的特征的说法正确的有", 
				"在每小题列出的四个备选项中只有一个是符合题目要求的，请用鼠标勾选出正确的选项。错选、多选或未选均无分。");
		//三、填空题
		Subject q7 = buildOtherQuestion(7, 3, 120, 3, 4.0, "填空题", "我国政府对海外投资实行的分级审批管理制度，决定审批权限归属是按照中方______。",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		Subject q8 = buildOtherQuestion(8, 3, 120, 3, 4.0, "填空题", "世界经济是一个经济范畴，也是一个______范畴。",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		Subject q9 = buildOtherQuestion(9, 3, 120, 3, 4.0, "填空题", "发展中国家以开放本国服务市场为交换条件，要求发达国家对其开放商品市场，这就是所谓的______论。",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		//四、名词解释题
		Subject q10 = buildOtherQuestion(10, 4, 121, 3, 8.0, "名词解释题", "专利",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		Subject q11 = buildOtherQuestion(11, 4, 121, 3, 8.0, "名词解释题", "履约保函",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		Subject q12 = buildOtherQuestion(12, 4, 121, 3, 8.0, "名词解释题", "货币自由兑换",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		//简答题
		Subject q13 = buildOtherQuestion(13, 5, 122, 3, 9.0, "简答题", "非关税壁垒与关税壁垒相比具有哪些特点？",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		Subject q14 = buildOtherQuestion(14, 5, 122, 3, 9.0, "简答题", "简述国际储备的作用。",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		Subject q15 = buildOtherQuestion(15, 5, 122, 3, 9.0, "简答题", "简要分析我国企业境外上市的有利因素有哪些？",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		//论述题
		Subject q16 = buildOtherQuestion(16, 6, 123, 1, 15.0, "论述题", "二战结束到现在已有70多年，在这70多年间，日本、韩国、中国等东亚的一些国家或地区相继实现经济高速增长，国际贸易商品结构也发生了明显变化，主要出口产品由最初的初级产品到劳动密集型产品，再到资本技术密集型产品，试根据所学的国际贸易理论对此变化进行解释。",
				"请在答题文本框内使用键盘输入答题内容，需要使用手写输入的可在答题文本框内点击“画图/手写输入”图标打开手写板输入程序，使用手写板书写并作为图片上传");
		list.add(q1);
		list.add(q2);
		list.add(q3);
		
		list.add(q4);
		list.add(q5);
		list.add(q6);
		
		list.add(q7);
		list.add(q8);
		list.add(q9);
		
		list.add(q10);
		list.add(q11);
		list.add(q12);
		
		list.add(q13);
		list.add(q14);
		list.add(q15);
		
		list.add(q16);
		
		return list;
	}

	public static String getQuestionPrefix(int i) {
		if (i == 1) {
			return "一";
		} else if (i == 2) {
			return "二";
		} else if (i == 3) {
			return "三";
		} else if (i == 4) {
			return "四";
		} else if (i == 5) {
			return "五";
		} else if (i == 6) {
			return "六";
		} else if (i == 7) {
			return "七";
		} else if (i == 8) {
			return "八";
		} else if (i == 9) {
			return "九";
		} else if (i == 10) {
			return "十";
		} else if (i == 11) {
			return "十一";
		} else if (i == 12) {
			return "十三";
		} else if (i == 13) {
			return "十二";
		} else if (i == 14) {
			return "十四";
		} else if (i == 15) {
			return "十五";
		}
		return String.valueOf(i);
	}
	
	/**
	 * 构造单选.
	 * @return
	 */
	private static Subject buildSingleSelect(int i, int bigPrefix, int questionTypeId, int questionSum, Double score,
			String bigCaption, String bigBody, String bigRemark) {
		Subject q1 = new Subject();
		q1.setSubjectId(i);
		q1.setSubjectNo("100" + i);//题号
		q1.setCourseId(3);//课程ID
		q1.setCourseName("邓小平理论" + i);//----重要
		q1.setQuestionTypeId(questionTypeId);//题型ID-单选题----重要
		q1.setTypeCaption(bigCaption);//"单项选择题","多选题"
		q1.setDry(bigBody);//题干----重要
		q1.setDifficult("易" + i);//预计难度
		q1.setChapter("第一章" + i);
		q1.setQuestionSum(questionSum);//大题括号内概述-小题数----重要
		q1.setScore(score);//每道题满分值---重要
		q1.setQuestionScores(score * questionSum);//大题括号内概述-大题总分----重要
		q1.setRemark(bigRemark);//大题描述---重要
		q1.setAnswer(i%2 == 0 ? "A" : "B");//答案
		q1.setSortNo(getQuestionPrefix(bigPrefix));//大题号----重要
		List<SubjectOption> optList1 = new ArrayList<SubjectOption>();
		
		SubjectOption op1 = new SubjectOption();
		op1.setRemark("侧耳内容");
		op1.setSubjectOptionId(1);
		op1.setSubjectOptionNo("A");
		op1.setSubjectId(i);
		op1.setSubjectOptionContent("xxx");
		
		SubjectOption op2 = new SubjectOption();
		op2.setRemark("呜呜呜呜");
		op2.setSubjectOptionId(2);
		op2.setSubjectOptionNo("B");
		op2.setSubjectId(i);
		op2.setSubjectOptionContent("xxxyy");
		
		SubjectOption op3 = new SubjectOption();
		op3.setRemark("我问问vv");
		op3.setSubjectOptionId(3);
		op3.setSubjectOptionNo("C");
		op3.setSubjectId(i);
		op3.setSubjectOptionContent("yzz");
		
		SubjectOption op4 = new SubjectOption();
		op4.setRemark("了就是打发");
		op4.setSubjectOptionId(4);
		op4.setSubjectOptionNo("C");
		op4.setSubjectId(i);
		op4.setSubjectOptionContent("hyzz");
		
		optList1.add(op1);
		optList1.add(op2);
		optList1.add(op3);
		optList1.add(op4);
		
		q1.setOptions(optList1);
		
		return q1;
	}
	
	/**
	 * 构造多选.
	 * @param Question
	 * @return
	 */
	private static Subject buildMultiySelect(int i, int bigPrefix, int questionTypeId, int questionSum, Double score,
			String bigCaption, String bigBody, String bigRemark) {
		Subject q1 = new Subject();
		q1.setSubjectId(i);
		q1.setSubjectNo("100" + i);//题号
		q1.setCourseId(3);//课程ID
		q1.setCourseName("邓小平理论" + i);//----重要
		q1.setQuestionTypeId(questionTypeId);//题型-单选题----重要
		q1.setTypeCaption(bigCaption);//"单项选择题","多选题"
		q1.setDry(bigBody);//题干----重要
		q1.setDifficult("易" + i);//预计难度
		q1.setChapter("第一章" + i);
		q1.setScore(score);//每个题目满分值
		q1.setQuestionSum(questionSum);//大题括号内概述-小题数----重要
		q1.setQuestionScores(score * questionSum);//大题括号内概述-大题总分----重要
		q1.setAnswer(i%2 == 0 ? "C" : "D");//答案
		q1.setSortNo(getQuestionPrefix(bigPrefix));//大题号----重要
		q1.setRemark(bigRemark);//大题描述---重要
		List<SubjectOption> optList1 = new ArrayList<SubjectOption>();
		
		SubjectOption op1 = new SubjectOption();
		op1.setRemark("侧耳内容");
		op1.setSubjectOptionId(1);
		op1.setSubjectOptionNo("A");
		op1.setSubjectId(i);
		op1.setSubjectOptionContent("xxx");
		
		SubjectOption op2 = new SubjectOption();
		op2.setRemark("呜呜呜呜");
		op2.setSubjectOptionId(2);
		op2.setSubjectOptionNo("B");
		op2.setSubjectId(i);
		op2.setSubjectOptionContent("xxxyy");
		
		SubjectOption op3 = new SubjectOption();
		op3.setRemark("我问问vv");
		op3.setSubjectOptionId(3);
		op3.setSubjectOptionNo("C");
		op3.setSubjectId(i);
		op3.setSubjectOptionContent("yzz");
		
		SubjectOption op4 = new SubjectOption();
		op4.setRemark("了就是打发");
		op4.setSubjectOptionId(4);
		op4.setSubjectOptionNo("C");
		op4.setSubjectId(i);
		op4.setSubjectOptionContent("hyzz");
		
		SubjectOption op5 = new SubjectOption();
		op5.setRemark("了就是打发");
		op5.setSubjectOptionId(5);
		op5.setSubjectOptionNo("C");
		op5.setSubjectId(i);
		op5.setSubjectOptionContent("hyzz");
		
		optList1.add(op1);
		optList1.add(op2);
		optList1.add(op3);
		optList1.add(op4);
		optList1.add(op5);
		
		q1.setOptions(optList1);
		
		return q1;
	}
	
	/**
	 * 构造填空题.
	 * @param Question
	 * @return
	 */
	private static Subject buildOtherQuestion(int i, int bigPrefix, int typeId, int questionSum, Double score,
			String bigCaption, String bigBody, String bigRemark) {
		Subject q1 = new Subject();
		q1.setSubjectId(i);
		q1.setSubjectNo("100" + i);//题号
		q1.setCourseId(3);//课程ID
		q1.setCourseName("邓小平理论" + i);//----重要
		q1.setQuestionTypeId(typeId);//题型-填空题----重要
		q1.setTypeCaption(bigCaption);//"单项选择题","多选题"
		q1.setDry(bigBody);//题干----重要
		q1.setSortNo(getQuestionPrefix(bigPrefix));//大题号----重要
		q1.setQuestionSum(questionSum);//大题括号内概述-小题数----重要
		q1.setScore(score);//每题满分值---重要
		q1.setQuestionScores(score * questionSum);//大题括号内概述-大题总分----重要
		q1.setRemark(bigRemark);//大题描述---重要
		q1.setDifficult("易" + i);//预计难度
		q1.setChapter("第一章" + i);
		q1.setSubjectContent(bigBody + "55");//非选择类题目的题干
		q1.setAnswer("这是标准答案" + i);//答案
		List<SubjectOption> optList1 = new ArrayList<SubjectOption>();
		q1.setOptions(optList1);
		return q1;
	}
	
	public static void main(String[] args) throws IOException, InterruptedException {
		//DocUtil.genBigQs("document.ftl", "D:\\11.docx", 15, "5", "75", "单项选择题", "只能选一个啊");
		//DocUtil.genWordHeader("header.ftl", "D:\\22.docx", 3, 5, "002135", "数学", "02363190601A");
//		String docPath = "G:\\javaFx\\LT-client\\papers\\02363190601\\02363190601A\\ques\\100.doc";
//		Process proc = Runtime.getRuntime().exec("cmd /c \"" + docPath + "\"");
//	    InputStream stderr = proc.getErrorStream();
//	    InputStreamReader isr = new InputStreamReader(stderr);
//	    BufferedReader br = new BufferedReader(isr);
//	    String line = null;
//	    while ( (line = br.readLine()) != null) {
//		    System.err.println(line);
//	    }
//	    int exitVal = proc.waitFor();
//	    if (exitVal == 0) {
//
//	    }
	}
}
