package com.ssj.sys.controller;

import com.alibaba.fastjson.JSON;
import com.ssj.bean.common.framework.core.domain.Response;
import com.ssj.bean.sys.sort.domain.Sort;
import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
import com.ssj.bean.weixin.zyb.domain.*;
import com.ssj.framework.basic.common.bean.SplitPage;
import com.ssj.framework.core.common.controller.BaseController;
import com.ssj.framework.core.util.StringUtil;
import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.sys.sort.service.SortService;
import com.ssj.service.weixin.library.service.ILibJoinService;
import com.ssj.service.weixin.zuoyb.service.*;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;

/** 
 * @author  ZhangCaibao 
 * @version 2017年7月4日 上午11:41:48 
 * 类说明 
 */
@RequestMapping("sys/zuoyb")
@Controller
public class SysZuoybController extends BaseController {
	
	
	private File file;
	
	
	
	 public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}


	@Autowired
	 private ZuoybCourseService zuoybCourseService;
	 /**
	  * 打分基础数据
	  */
	 @Autowired
	 private ZuoybScoringContentService zuoybScoringContentService;
	 @Autowired
	 private ZuoybScoringContentDetailsService zuoybScoringContentDetailsService;
	 @Autowired
	 private SortService sortService;
	
 	 @Autowired
	 private ILibJoinService libJoinService;
 	 
	 @Autowired
	 private ZuoybWeekService zuoybWeekService;
	 @Autowired
	 private ZuoybWeekTeacherService zuoybWeekTeacherService;
	 @Autowired
	 private ZuoybKnowHowService  zuoybKnowHowService;
	 @Autowired
	 private ZuoybKnowHowDetailsService  zuoybKnowHowDetailsService;
	 
	 //作业大纲
	 @Autowired
	 private  ZuoybStudentWorkHowService   zuoybStudentWorkHowService;
	 
	 //作业大纲
	 @Autowired
	 private  ZuoybStudentBgService   zuoybStudentBgService;
	 //作业大纲
	 @Autowired
	 private  ZuoybKnowHowDetailsSortService   zuoybKnowHowDetailsSortService;
	 @Autowired
	 private  ZuoybKnowHowDetailsKdService   zuoybKnowHowDetailsKdService;
	/** 
	 * 
	 * 基础数据入口
	* @param model)))))
	* @param pageSize
	* @param pageNo
	* @param EQ_libId
	* @return
	* @throws Exception
	* 创建人：ZhangCaibao 
	* 2017年7月17日 下午3:57:09 
	* @String
	 */
	@RequestMapping("/zuoybCourseList")
	public String zuoybCourseList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,String EQ_libId)
				throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		 params.put("EQ_libId", EQ_libId);
		 params.put("course_name", request.getParameter("course_name")==null?"":request.getParameter("course_name"));
		SplitPage sp = new SplitPage();
	        sp.setAction(request.getRequestURI().toString());
	        sp.setPageNo(pageNo);
	        sp.setPageSize(pageSize);
	        sp.setParams(params);
	    Page<Map<String, Object>>  page= zuoybCourseService.getZuoybCourseist(params, initPage(pageNo,pageSize));
		sp.setRowCnt((int) page.getTotalElements());
		model.addAttribute("list", page.getContent());
		model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
		model.addAttribute("page", sp);
		model.addAttribute("search", params);
			return "sys/zuoyb/zuoybCourseList";
	}
	
	  @RequestMapping("/zuoybCourseAdd")
	  public String zuoybCourseAdd(Model model,@RequestParam( defaultValue = "0")String id,String  libId) throws Exception {
		     model.addAttribute("libId", libId);
			 model.addAttribute("zyb_course", sortService.getParamValByCode("zyb_course"));
			 model.addAttribute("zyb_hour", sortService.getParamValByCode("zyb_hour"));
			 return "sys/zuoyb/zuoybCourseAdd";
	 }
		 @RequestMapping(value = "/zuoybCourseListSave", method = RequestMethod.POST)
		 @ResponseBody
		 public Response zuoybCourseListSave(@RequestParam(value = "courseName")String courseName,
											 @RequestParam(value = "courseHour")String courseHour,
											 @RequestParam(value = "libId")String libId) {
			 Response response = new Response();
			 try {
				 String courseHours[]=courseHour.split(",");
				 if(courseHours.length>0){
					 Sort sortname = sortService.getById(courseName);
					 for (int i = 0; i < courseHours.length; i++) {
						 Sort  sort= sortService.getById(courseHours[i]);
						 if(sort ==null){
							 continue;
						 }
						 Integer count=zuoybCourseService.getCourseNameAndHourAndLibId(sortname.getName(), sort.getName(), libId);
						 if(count>0){
							 continue;
						 }
						 ZuoybCourse zuoybCourse  =new  ZuoybCourse();
						 zuoybCourse.setCourseName(sortname.getName());
						 zuoybCourse.setCourseHour(sort.getName());
						 zuoybCourse.setLibId(libId);
						 zuoybCourse.setDetails(sort.getAliases());
						 zuoybCourse.setCreateTime(new Date());
						 zuoybCourse.setIcon(sortname.getAliases());
						 zuoybCourse.setNum(zuoybCourseService.fingByCourseHourAndLibIdCount(sort.getName(), libId)+1);
						 zuoybCourse=zuoybCourseService.save(zuoybCourse);
						 zuoybScoringContentService.insertLibIdScoringContent(libId, zuoybCourse.getId(),sortname.getCode());
						 zuoybCourseService.insertZuoybWeekList(zuoybCourse.getId(), libId);
					}
				 }
				 response.success("添加成功");
			 } catch (Exception e) {
				 e.printStackTrace();
				 response.failure("添加失败：" + e.getMessage());
			 }
			 return response;
		 } 	
		 /**
		  * 批量生成作业吧基础数据和课程和时段
		 * @return
		 * 创建人：ZhangCaibao 
		 * 2017年9月15日 下午1:31:41 
		 * @Response
		  */
		 @RequestMapping(value = "/batchZuoybScoringSave")
		 @ResponseBody
		 public Response batchZuoybScoringSave() {
			 Response response = new Response();
			 try {
				 List<TbLibJoin> list  =  libJoinService.findAll();
				 //插入基础数据
				 zuoybScoringContentService.bathInsertZuoybScoringContent(list);
				 
				 List<Sort> courseList= sortService.getParamValByCode("zyb_course");
				 List<Sort> hourList= sortService.getParamValByCode("zyb_hour");
				 for (TbLibJoin join : list) {
					 for (Sort sortHour : hourList) {
						 for (Sort sortCourse : courseList) {
							 Integer count=zuoybCourseService.getCourseNameAndHourAndLibId(sortCourse.getName(), sortHour.getName(), join.getId());
							 if(count>0){
								 continue;
							 }
							 ZuoybCourse   zuoybCourse  =new  ZuoybCourse();
							 zuoybCourse.setCourseName(sortCourse.getName());
							 zuoybCourse.setCourseHour(sortHour.getName());
							 zuoybCourse.setLibId(join.getId());
							 zuoybCourse.setDetails(sortHour.getAliases());
							 zuoybCourse.setCreateTime(new Date());
							 zuoybCourse.setIcon(sortCourse.getAliases());
							 zuoybCourse.setNum(zuoybCourseService.fingByCourseHourAndLibIdCount(sortHour.getName(), join.getId())+1);
							 zuoybCourse=zuoybCourseService.save(zuoybCourse);
							 zuoybScoringContentService.insertLibIdScoringContent(join.getId(), zuoybCourse.getId(),sortCourse.getCode());
							 zuoybCourseService.insertZuoybWeekList(zuoybCourse.getId(), join.getId());
						 }
					 }
				 }
				 response.success("添加成功");
			 } catch (Exception e) {
				 e.printStackTrace();
				 response.failure("添加失败：" + e.getMessage());
			 }
			 return response;
		 } 	
		 /**
		  * 批量所有馆插入课程知识点
		 * @return
		 * 创建人：ZhangCaibao 
		 * 2017年9月27日 下午5:16:59 
		 * @Response
		  */
		 @RequestMapping(value = "/batchKonwHowSave")
		 @ResponseBody
		 public Response batchKonwHowSave() {
			 Response response = new Response();
			 try {
				 List<TbLibJoin> list  =  libJoinService.findAll();
				 //插入基础数据
				 for (TbLibJoin tbLibJoin : list) {
					 zuoybKnowHowService.insertKonwHow(tbLibJoin.getId());
				}
				 response.success("添加成功");
			 } catch (Exception e) {
				 e.printStackTrace();
				 response.failure("添加失败：" + e.getMessage());
			 }
			 return response;
		 } 	
		 /**
		  * 获取作业吧的管理员
		 * @param model
		 * @param pageSize
		 * @param pageNo
		 * @return
		 * @throws Exception
		 * 创建人：ZhangCaibao 
		 * 2017年7月4日 下午2:42:55 
		 * @String
		  */
		    @RequestMapping("/selectZybList")
		    public String selectZybList(Model model,
		    		@RequestParam(required = false, defaultValue = "10") int pageSize,
		    		@RequestParam(required = false, defaultValue = "1") int pageNo ) throws Exception {
		    	Map<String, Object> params = new HashMap<String, Object>();
		    	params.put("name", request.getParameter("name")==null?"":request.getParameter("name"));
		    	params.put("type", request.getParameter("type")==null?"":request.getParameter("type"));
		    	params.put("weekId", request.getParameter("weekId"));
		    	params.put("courseHour", request.getParameter("courseHour"));
		    	params.put("days", request.getParameter("days"));
		    	params.put("libId", request.getParameter("libId"));
		    	params.put("zybCourseId", request.getParameter("zybCourseId"));
		    	SplitPage sp = new SplitPage();
		    	sp.setAction(request.getRequestURI().toString());
		    	sp.setPageNo(pageNo);
		    	sp.setPageSize(pageSize);
		    	sp.setParams(params);
		    	Page<Map<String, Object>> page= zuoybCourseService.getZybList(params, initPage(pageNo,pageSize));
		    	sp.setRowCnt((int)page.getTotalElements());
		    	model.addAttribute("list",  page.getContent());
		    	model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
		    	model.addAttribute("page", sp);
		    	model.addAttribute("search", params);
		    	
		    	return "sys/zuoyb/selectZybList";
		    }
	/**	    
	 * 单个课程批量加SR导师
	* @param libId
	* @return
	* 创建人：ZhangCaibao 
	* 2017年9月6日 下午6:22:12 
	* @Response
	 */
    @RequestMapping(value = "/bachSaveWeekTeacherId", method = RequestMethod.POST)
	@ResponseBody
	public Response bachSaveWeekTeacherId(@RequestParam(value = "libId")String libId,
			@RequestParam(value = "days")Integer days,@RequestParam(value = "courseHour")String courseHour,
			@RequestParam(value = "ids[]")String[] ids,@RequestParam(value = "weekId")String weekId
			,@RequestParam(value = "zybCourseId")String zybCourseId) {
				 Response response = new Response();
				 try {
					 if(ids.length>0){
						 List<ZuoybWeekTeacher>  teacherlist = new  ArrayList<ZuoybWeekTeacher>();
			 	       		for (int i = 0; i < ids.length; i++) {
				 	       		Integer count=zuoybWeekTeacherService.getWeekIdAndteacherIdCount(weekId, ids[i]);
			 	       			if(count>0)continue;
				 	       		ZuoybWeekTeacher  teacher = new  ZuoybWeekTeacher();
		 	       				teacher.setCreateTime(new Date());
		 	       				teacher.setCourseHour(courseHour);
		 	       				teacher.setDays(days);teacher.setLibId(libId);
		 	       				teacher.setZybCourseId(zybCourseId);
		 	       				teacher.setZybWeekId(weekId);
		 	       				teacher.setTeacherId(ids[i]);
		 	       				teacherlist.add(teacher);
			 	       		}
			 	       		zuoybWeekTeacherService.save(teacherlist);
			 	     }
					 response.success("添加成功");
				 } catch (Exception e) {
					 e.printStackTrace();
					 response.failure("添加失败：" + e.getMessage());
				 }
				 return response;
	 } 
    /**
     *  单个课程批量删除SR导师
    * @param libId
    * @param days
    * @param courseHour
    * @param ids
    * @param weekId
    * @return
    * 创建人：ZhangCaibao 
    * 2017年9月6日 下午6:22:44 
    * @Response
     */
    @RequestMapping(value = "/bachDeleteWeekTeacherId", method = RequestMethod.POST)
    @ResponseBody
    public Response bachDeleteWeekTeacherId(@RequestParam(value = "libId")String libId,
    		@RequestParam(value = "days")Integer days,@RequestParam(value = "courseHour")String courseHour,
    		@RequestParam(value = "ids[]")String[] ids,@RequestParam(value = "weekId")String weekId
			,@RequestParam(value = "zybCourseId")String zybCourseId) {
    	Response response = new Response();
    	try {
    		if(ids.length>0){
 	       		for (int i = 0; i < ids.length; i++) {
 	       			zuoybWeekTeacherService.deleteByTeacherIdAndWeekId(weekId,ids[i]);
 	       		}
 	       	}
    		response.success("添加成功");
    	} catch (Exception e) {
    		e.printStackTrace();
    		response.failure("添加失败：" + e.getMessage());
    	}
    	return response;
    } 			    
	 @RequestMapping(value = "/zuoybCourseDelete", method = RequestMethod.POST)
	 @ResponseBody
	 public Response zuoybCourseDelete( 
					 @RequestParam(value = "id")String id) {
				 Response response = new Response();
				 try {
					 zuoybCourseService.zuoybCourseDelete(id);
					 response.success("添加成功");
				 } catch (Exception e) {
					 e.printStackTrace();
					 response.failure("添加失败：" + e.getMessage());
				 }
				 return response;
	}
	 /**
	  * 打分内容基础数据
	 * @param model
	 * @param pageSize
	 * @param pageNo
	 * @param EQ_libId
	 * @return
	 * @throws Exception
	 * 创建人：ZhangCaibao 
	 * 2017年7月4日 下午6:22:18 
	 * @String
	  */
		@RequestMapping("/scoringContentList")
		public String scoringContentList(Model model,
					@RequestParam(required = false, defaultValue = "10") int pageSize,
					@RequestParam(required = false, defaultValue = "1") int pageNo,
					@RequestParam(required = false, defaultValue = "1") int type,
					@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
					String EQ_zybCourseId)
					throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_libId", EQ_libId);
			params.put("EQ_zybCourseId", EQ_zybCourseId !=null ? EQ_zybCourseId : EQ_libId);
			params.put("LIKE_content",request.getParameter("LIKE_content")==null?"":request.getParameter("LIKE_content"));
			Page<ZuoybScoringContent> page= zuoybScoringContentService.findByPage(params, initPage(pageNo,pageSize,Direction.ASC, new String[] { "num" }));
			params.put("type", type);
			SplitPage sp = new SplitPage();
		    sp.setAction(request.getRequestURI().toString());
		    sp.setPageNo(pageNo);
		    sp.setPageSize(pageSize);
		    sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
				return "sys/zuoyb/scoringContentList";
		}
		  @RequestMapping("/scoringContentAdd")
		  public String scoringContentAdd(Model model,@RequestParam( defaultValue = "0")String id,
				  Integer type,
				  String  libId) throws Exception {
			  ZuoybScoringContent  content= zuoybScoringContentService.getById(id);
			  if(content ==null){
				  content = new  ZuoybScoringContent();
				  content.setLibId(libId);
				  content.setZybCourseId(libId);
				  content.setType(type);
			  }
			     model.addAttribute("content", content);
				 return "sys/zuoyb/scoringContentAdd";
		 }	
		 /** 
		  * 打分基础数据的保存
		 * @param content
		 * @return
		 * 创建人：ZhangCaibao 
		 * 2017年7月5日 上午10:40:51 
		 * @Response
		  */
		@RequestMapping(value = "/scoringContentSave", method = RequestMethod.POST)
		@ResponseBody
		public Response scoringContentSave( ZuoybScoringContent  content) {
				 Response response = new Response();
				 content.setCreateTime(new Date());
				 zuoybScoringContentService.save(content);
				 response.success("添加成功");
				 return response;
		}
		 @RequestMapping(value = "/scoringContenDelete", method = RequestMethod.POST)
		 @ResponseBody
		public Response scoringContenDelete( 
						 @RequestParam(value = "id")String id) {
					 Response response = new Response();
						 zuoybScoringContentService.delete(id);
						 zuoybScoringContentDetailsService.deleteByScoringContentId(id);
						 response.success("删除成功");
					 return response;
		}	
		 /**
		  *  基础数据明细，有单选，有文本，
		 * @param model
		 * @param pageSize
		 * @param pageNo
		 * @param type
		 * @param EQ_libId
		 * @param EQ_zybCourseId
		 * @return
		 * @throws Exception
		 * 创建人：ZhangCaibao 
		 * 2017年7月5日 上午11:22:24 
		 * @String
		  */
		 @RequestMapping("/scoringContenDetailList")
		 public String scoringContenDetailList(Model model,
				 @RequestParam(required = false, defaultValue = "10") int pageSize,
				 @RequestParam(required = false, defaultValue = "1") int pageNo,
				 @RequestParam(required = false, defaultValue = "1") int type,
				 @RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
				 String EQ_zybCourseId,
				 String EQ_scoringContentId)
						 throws Exception {
			 Map<String, Object> params = new HashMap<String, Object>();
			 params.put("EQ_libId", EQ_libId);
			 params.put("EQ_scoringContentId", EQ_scoringContentId !=null ? EQ_scoringContentId : EQ_libId);
			 params.put("LIKE_content",request.getParameter("LIKE_content")==null?"":request.getParameter("LIKE_content"));
			 Page<ZuoybScoringContentDetails> page= zuoybScoringContentDetailsService.findByPage(params, initPage(pageNo,pageSize,Direction.ASC, new String[] { "num" }));
			 params.put("EQ_zybCourseId", EQ_zybCourseId);
			 SplitPage sp = new SplitPage();
			 sp.setAction(request.getRequestURI().toString());
			 sp.setPageNo(pageNo);
			 sp.setPageSize(pageSize);
			 sp.setParams(params);
			 sp.setRowCnt((int) page.getTotalElements());
			 model.addAttribute("list", page.getContent());
			 model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			 model.addAttribute("page", sp);
			 params.put("type", type);
			 model.addAttribute("search", params);
			 return "sys/zuoyb/scoringContenDetailList";
		 }

		  @RequestMapping("/scoringContenDetailAdd")
		  public String scoringContenDetailAdd(Model model,@RequestParam( defaultValue = "0")String id,
				  Integer type,String EQ_scoringContentId,String  EQ_zybCourseId,
				  String  libId) throws Exception {
			  ZuoybScoringContentDetails  content= zuoybScoringContentDetailsService.getById(id);
			  if(content ==null){
				  content = new  ZuoybScoringContentDetails();
				  content.setLibId(libId);
				  content.setScoringContentId(EQ_scoringContentId);
				  content.setType(type);
			  }
			     model.addAttribute("content", content);
			     model.addAttribute("type", type);
			     model.addAttribute("EQ_zybCourseId", EQ_zybCourseId);
				 return "sys/zuoyb/scoringContenDetailAdd";
		 }	
		 /** 
		  * 打分基础数据的保存
		 * @param content
		 * @return
		 * 创建人：ZhangCaibao 
		 * 2017年7月5日 上午10:40:51 
		 * @Response
		  */
		@RequestMapping(value = "/scoringContenDetailSave", method = RequestMethod.POST)
		@ResponseBody
		public Response scoringContenDetailSave( ZuoybScoringContentDetails  content) {
				 Response response = new Response();
				 content.setCreateTime(new Date());
				 zuoybScoringContentDetailsService.save(content);
				 response.success("添加成功");
				 return response;
		}
		 @RequestMapping(value = "/scoringContenDetailDelete", method = RequestMethod.POST)
		 @ResponseBody
		public Response scoringContenDetailDelete( 
						 @RequestParam(value = "id")String id) {
					 Response response = new Response();
					 zuoybScoringContentDetailsService.delete(id);
						 response.success("删除成功");
					 return response;
		}
		 /**
		  * 获取该馆的基本数据
		 * @param model
		 * @param pageSize
		 * @param pageNo
		 * @return
		 * @throws Exception
		 * 创建人：ZhangCaibao 
		 * 2017年7月5日 下午4:32:14 
		 * @String
		  */
		    @RequestMapping("/selectContentList")
		    public String selectContentList(Model model,
		    		@RequestParam(required = false, defaultValue = "10") int pageSize,
		    		@RequestParam(required = false, defaultValue = "1") int pageNo,
		    		String EQ_libId,String zybCourseId ) throws Exception {
		    	Map<String, Object> params = new HashMap<String, Object>();
		    	params.put("EQ_libId", EQ_libId);
		    	params.put("EQ_zybCourseId", EQ_libId);
		    	params.put("EQ_type", "2");
				params.put("LIKE_content",request.getParameter("LIKE_content")==null?"":request.getParameter("LIKE_content"));
				Page<ZuoybScoringContent> page= zuoybScoringContentService.findByPage(params, initPage(pageNo,pageSize,Direction.ASC, new String[] { "num" }));
				params.put("zybCourseId", zybCourseId);
				SplitPage sp = new SplitPage();
			        sp.setAction(request.getRequestURI().toString());
			        sp.setPageNo(pageNo);
			        sp.setPageSize(pageSize);
			        sp.setParams(params);
				sp.setRowCnt((int) page.getTotalElements());
				model.addAttribute("list", page.getContent());
				model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
				model.addAttribute("page", sp);
				model.addAttribute("search", params);
		    	return "sys/zuoyb/selectContentList";
		    }		 
		 @RequestMapping(value = "/selectContentSave", method = RequestMethod.POST)
		 @ResponseBody
		 public Response selectContentSave(@RequestParam(value = "zybCourseId")String zybCourseId,
				    @RequestParam(value = "libId")String libId, 
		 			@RequestParam(value = "ids[]")String[] ids) {
		    	Response response = new Response();
		    	zuoybScoringContentService.selectContentSave(zybCourseId, libId, ids);
		    	response.success("添加成功");
		    	return response;
		 }
	@RequestMapping(value = "/validateNum", method = RequestMethod.POST)
	@ResponseBody
	public boolean validateNum(Integer oldNum,Integer num ,String zybCourseId,String libId) {
		        if(oldNum.equals(num)){
		        	 return true;
		        };
		        Integer count =zuoybCourseService.getZybCourseIdAndLibIdAndNum(num, zybCourseId, libId);
		        if(count==0){ return true;}
		        return false;
	}
	
	/**
	 * 总部配置各个馆SR老师
	* @param model
	* @param pageSize
	* @param pageNo
	* @return
	* @throws Exception
	* 创建人：ZhangCaibao 
	* 2017年9月6日 下午3:55:25 
	* @String
	 */
	@RequestMapping("/zuoybSRList")
	public String zuoybSRList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo)
				throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		 params.put("EQ_libId", request.getParameter("EQ_libId")==null?"":request.getParameter("EQ_libId"));
		 if(!"admin".equals(loginName())){
				params.put("orgCode", orgCodeStr());
			}
		SplitPage sp = new SplitPage();
	        sp.setAction(request.getRequestURI().toString());
	        sp.setPageNo(pageNo);
	        sp.setPageSize(pageSize);
	        sp.setParams(params);
	    Page<Map<String, Object>>  page= zuoybCourseService.zuoybSRList(params, initPage(pageNo,pageSize));
		sp.setRowCnt((int) page.getTotalElements());
		model.addAttribute("list", page.getContent());
		model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
		model.addAttribute("page", sp);
		model.addAttribute("search", params);
		model.addAttribute("libList",libJoinService.getLibJoinByCode(orgcodeList()));
			return "sys/zuoyb/zuoybSRList";
	}
	/**
	 * 选中查询全部SR老师，已选的默认选中
	* @param model
	* @param pageSize
	* @param pageNo
	* @return
	* @throws Exception
	* 创建人：ZhangCaibao 
	* 2017年9月6日 下午3:55:41 
	* @String
	 */
    @RequestMapping("/selectZybSRList")
    public String selectZybSRList(Model model,
    		@RequestParam(required = false, defaultValue = "10") int pageSize,
    		@RequestParam(required = false, defaultValue = "1") int pageNo ) throws Exception {
    	Map<String, Object> params = new HashMap<String, Object>();
    	params.put("name", request.getParameter("name")==null?"":request.getParameter("name"));
    	params.put("type", request.getParameter("type")==null?"":request.getParameter("type"));
    	params.put("days", request.getParameter("days"));
    	params.put("libId", request.getParameter("libId"));
    	params.put("courseHour", request.getParameter("courseHour"));
    	SplitPage sp = new SplitPage();
    	sp.setAction(request.getRequestURI().toString());
    	sp.setPageNo(pageNo);
    	sp.setPageSize(pageSize);
    	sp.setParams(params);
    	Page<Map<String, Object>> page= zuoybCourseService.selectZybSRList(params, initPage(pageNo,pageSize));
    	sp.setRowCnt((int)page.getTotalElements());
    	model.addAttribute("list",  page.getContent());
    	model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
    	model.addAttribute("page", sp);
    	model.addAttribute("search", params);
    	
    	return "sys/zuoyb/selectZybSRList";
    }
    /**
     * 批量保存SR老师
    * @param libId
    * @param days
    * @param courseHour
    * @param ids
    * @return
    * 创建人：ZhangCaibao 
    * 2017年9月6日 下午3:53:48 
    * @Response
     */
	@RequestMapping(value = "/bachAddSRTeacher", method = RequestMethod.POST)
 	@ResponseBody
 	public Response bachAddSRTeacher(@RequestParam(value = "libId")String libId,
 			@RequestParam(value = "days")Integer days,@RequestParam(value = "courseHour")String courseHour,
 			@RequestParam(value = "ids[]")String[] ids) {
 	        Response response = new Response();
 	        try {
 	       	if(ids.length>0){
 	       		List<ZuoybWeek> list=	zuoybWeekService.findByLibIdAndDaysAndHour(libId, days, courseHour);
 	       		if(list!=null && list.size()>0){
 	       		List<ZuoybWeekTeacher>  teacherlist = new  ArrayList<ZuoybWeekTeacher>();
 	       		for (ZuoybWeek zuoybWeek : list) {
 	       			for (int i = 0; i < ids.length; i++) {
		 	       			Integer count=zuoybWeekTeacherService.getWeekIdAndteacherIdCount(zuoybWeek.getId(), ids[i]);
		 	       			if(count>0)continue;
	 	       				ZuoybWeekTeacher  teacher = new  ZuoybWeekTeacher();
	 	       				teacher.setCreateTime(new Date());
	 	       				teacher.setCourseHour(courseHour);
	 	       				teacher.setDays(days);teacher.setLibId(libId);
	 	       				teacher.setZybCourseId(zuoybWeek.getZybCourseId());
	 	       				teacher.setZybWeekId(zuoybWeek.getId());
	 	       				teacher.setTeacherId(ids[i]);
	 	       				teacherlist.add(teacher);
 	       			}
 	       		}
 	       		zuoybWeekTeacherService.save(teacherlist);
 	       		}
 	       	}
 	            response.success("添加成功");
 	        } catch (Exception e) {
 	            e.printStackTrace();
 	            response.failure("添加失败：" + e.getMessage());
 	        }
 	        return response;
 	 } 
	/**
	 * 批量删除SR老师
	* @param libId
	* @param days
	* @param courseHour
	* @param ids
	* @return
	* 创建人：ZhangCaibao 
	* 2017年9月6日 下午3:55:00 
	* @Response
	 */
	@RequestMapping(value = "/bachDeleteSRTeacher", method = RequestMethod.POST)
	@ResponseBody
	public Response bachDeleteSRTeacher(@RequestParam(value = "libId")String libId,
			@RequestParam(value = "days")Integer days,@RequestParam(value = "courseHour")String courseHour,
			@RequestParam(value = "ids[]")String[] ids) {
		Response response = new Response();
		try {
		 	if(ids.length>0){
 	       		for (int i = 0; i < ids.length; i++) {
 	       			zuoybWeekTeacherService.deleteByTeacherIdAndLibIdAndcourseHour(ids[i], libId, courseHour, days);
 	       		}
 	       	}
			response.success("添加成功");
		} catch (Exception e) {
			e.printStackTrace();
			response.failure("添加失败：" + e.getMessage());
		}
		return response;
	}
	
	 @RequestMapping(value = "/updateCourseNum", method = RequestMethod.POST)
	 @ResponseBody
	 public Response updateCourseNum( String id,Integer  num){
		 Response response = new  Response();
		 zuoybCourseService.updateCourseNum(id, num);
		 response.success();
		 return response;
	 }
	 
	 
	 /**
	  * 作业知识点基础数据
	 * @param model
	 * @param pageSize
	 * @param pageNo
	 * @param EQ_libId
	 * @return
	 * @throws Exception
	 * 创建人：ZhangCaibao 
	 * 2017年7月4日 下午6:22:18 
	 * @String
	  */
		@RequestMapping("/knowHowList")
		public String knowHowList(Model model,
					@RequestParam(required = false, defaultValue = "10") int pageSize,
					@RequestParam(required = false, defaultValue = "1") int pageNo,
					@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId)
					throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_libId", EQ_libId);
			params.put("LIKE_name",request.getParameter("LIKE_name")==null?"":request.getParameter("LIKE_name"));
			params.put("EQ_grade",request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));//年级
			params.put("EQ_courseName",request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
			params.put("semester",request.getParameter("semester")==null?"":request.getParameter("semester"));//学期
			params.put("banben",request.getParameter("banben")==null?"":request.getParameter("banben"));//版本
			params.put("beginDate", request.getParameter("beginDate")==null? "":request.getParameter("beginDate"));
			params.put("endDate", request.getParameter("endDate")==null? "":request.getParameter("endDate"));
			params.put("LIKE_id", request.getParameter("LIKE_id")==null?"":request.getParameter("LIKE_id"));

			
			
			Page<Map<String, Object>> page= zuoybKnowHowService.getZuoybKnowHow(params, initPage(pageNo,pageSize));
			SplitPage sp = new SplitPage();
		    sp.setAction(request.getRequestURI().toString());
		    sp.setPageNo(pageNo);
		    sp.setPageSize(pageSize);
		    sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
			model.addAttribute("zyb_course", sortService.getParamValByCode("zyb_course"));
			model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
			
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
				return "sys/zuoyb/knowHowList";
		}
		@RequestMapping("/getknowHowList")
		public String getknowHowList(Model model,
				@RequestParam(required = false, defaultValue = "20") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,
				@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
				String sortId,String howId
				)
						throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_libId", EQ_libId);
			params.put("LIKE_name",request.getParameter("LIKE_name")==null?"":request.getParameter("LIKE_name"));
			params.put("EQ_grade",request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));//年级
			params.put("EQ_courseName",request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
			params.put("semester",request.getParameter("semester")==null?"":request.getParameter("semester"));//学期
			params.put("banben",request.getParameter("banben")==null?"":request.getParameter("banben"));//版本
			
			
			
			Page<Map<String, Object>> page= zuoybKnowHowService.getZuoybKnowHow(params, initPage(pageNo,pageSize));
			params.put("sortId",request.getParameter("sortId")==null?"":request.getParameter("sortId"));//版本
			SplitPage sp = new SplitPage();
			sp.setAction(request.getRequestURI().toString());
			sp.setPageNo(pageNo);
			sp.setPageSize(pageSize);
			sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
		
			model.addAttribute("zyb_course", sortService.getParamValByCode("zyb_course"));
			model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/getknowHowList";
		}
		@RequestMapping(value = "/saveSortHowId", method = RequestMethod.POST)
		@ResponseBody
		public Response saveSortHowId( String howId,String sortId) {
				 Response response = new Response();
				 ZuoybKnowHowDetailsSort  sort = zuoybKnowHowDetailsSortService.getById(sortId);
				 sort.setHowId(howId);
				 zuoybKnowHowDetailsSortService.save(sort);
				 response.success("添加成功");
				 return response;
		}
		@RequestMapping(value = "/saveSortHowDetilsId", method = RequestMethod.POST)
		@ResponseBody
		public Response saveSortHowDetilsId( String howDetailsId,String sortId) {
			Response response = new Response();
			ZuoybKnowHowDetailsSort  sort = zuoybKnowHowDetailsSortService.getById(sortId);
			sort.setHowDetailsId(howDetailsId);
			zuoybKnowHowDetailsSortService.save(sort);
			response.success("添加成功");
			return response;
		}
		/**
		 * 新增作业知识点基础数据
		* @param model
		* @param id
		* @param libId
		* @return
		* @throws Exception
		* 创建人：ZhangCaibao 
		* 2017年9月26日 下午3:10:39 
		* @String
		 */
		  @RequestMapping("/knowHowAdd")
		  public String knowHowAdd(Model model,@RequestParam( defaultValue = "0")String id,
				  String  libId) throws Exception {
			  ZuoybKnowHow  how= zuoybKnowHowService.getById(id);
			  if(how ==null){
				  how = new  ZuoybKnowHow();
				  how.setLibId(libId);
				  how.setIsZt(0);
				  
				  model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
			  }
			  model.addAttribute("zyb_course", sortService.getParamValByCode("zyb_course"));
			     model.addAttribute("how", how);
			     model.addAttribute("versions", SystemResourceLocator.getVersionList());
				 return "sys/zuoyb/knowHowAdd";
		 }
		  
		 /** 
		  * 作业知识点基础数据保存
		 * @return
		 * 创建人：ZhangCaibao 
		 * 2017年7月5日 上午10:40:51 
		 * @Response
		  */
		@RequestMapping(value = "/knowHowSave", method = RequestMethod.POST)
		@ResponseBody
		public Response knowHowSave(ZuoybKnowHow how) {
			Response response = new Response();
			how.setCreateTime(new Date());
			how = zuoybKnowHowService.save(how);
			String[] version = how.getVersion();
			if (version != null && version.length > 0) {
				String grade = "";
				List<Sort> list = sortService.getParamValByCode("grade");
				Integer gradeNum = how.getGradeNum();
				for (Sort sort : list) {
					if (sort.getAliases().equals(gradeNum.toString())) {
						grade = sort.getName();
						break;
					}
				}
				for (String string : version) {
					ZuoybKnowHowDetailsSort howsort = new ZuoybKnowHowDetailsSort();
					howsort.setCreateTime(new Date());
					howsort.setType(Integer.parseInt(string));
					howsort.setHowId(how.getId());
					howsort.setCourseName(how.getCourseName());
					howsort.setNum(how.getNum());
					howsort.setAlias(how.getName());
					howsort.setLibId(how.getLibId());
					howsort.setStat(1);
					howsort.setGrade(grade);
					howsort.setGradeNum(how.getGradeNum());
					howsort.setSemester(how.getSemester());
					zuoybKnowHowDetailsSortService.save(howsort);
				}
			}
			response.success("添加成功");
			return response;
		}

		
		 @RequestMapping(value = "/updateKnowHowNum", method = RequestMethod.POST)
		 @ResponseBody
		 public Response updateKnowHowNum( String id,Integer  num){
			 Response response = new  Response();
			 zuoybKnowHowService.updateKnowHowNum(id, num);
			 response.success();
			 return response;
		 }
		 
			@RequestMapping("/knowHowVersionList")
			public String knowHowVersionList(Model model,
					@RequestParam(required = false, defaultValue = "10") int pageSize,
					@RequestParam(required = false, defaultValue = "1") int pageNo,
					@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
					@RequestParam(required = false, defaultValue = "1") String EQ_stat,
					String EQ_howId)
							throws Exception {
				Map<String, Object> params = new HashMap<String, Object>();
				params.put("EQ_howId", EQ_howId);
				params.put("EQ_libId", EQ_libId);
				params.put("LIKE_alias",request.getParameter("LIKE_alias")==null?"":request.getParameter("LIKE_alias"));
				params.put("EQ_gradeNum",request.getParameter("EQ_gradeNum")==null?"":request.getParameter("EQ_gradeNum"));//年级
			//	params.put("EQ_courseName",request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
				params.put("EQ_semester",request.getParameter("EQ_semester")==null?"":request.getParameter("EQ_semester"));//学期
				params.put("EQ_type",request.getParameter("EQ_type")==null?"":request.getParameter("EQ_type"));//版本

				params.put("EQ_id",request.getParameter("EQ_id")==null?"":request.getParameter("EQ_id"));
				params.put("EQ_stat",EQ_stat);//单元
				
				Pageable pageable =initPage(pageNo,pageSize,Direction.ASC, new String[] { "gradeNum","semester" ,"num" ,"createTime"  });
				Page<ZuoybKnowHowDetailsSort> page= zuoybKnowHowDetailsSortService.findByPage(params, pageable);
				SplitPage sp = new SplitPage();
				sp.setAction(request.getRequestURI().toString());
				sp.setPageNo(pageNo);
				sp.setPageSize(pageSize);
				sp.setParams(params);
				sp.setRowCnt((int) page.getTotalElements());
				model.addAttribute("list", page.getContent());
				model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
				model.addAttribute("page", sp);
				model.addAttribute("search", params);
				model.addAttribute("grade", sortService.getParamValByCode("grade"));
			//	model.addAttribute("zyb_course", sortService.getParamValByCode("zyb_course"));
				model.addAttribute("versions", SystemResourceLocator.getVersionList());
				return "sys/zuoyb/knowHowVersionList";
			}
			@RequestMapping("/knowHowDetailKdVersionList")
			public String knowHowDetailKdVersionList(Model model,
					@RequestParam(required = false, defaultValue = "10") int pageSize,
					@RequestParam(required = false, defaultValue = "1") int pageNo,
					@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
					@RequestParam(required = false, defaultValue = "3") String EQ_stat,
					String EQ_howId,String EQ_howDetailsId,String EQ_howDetailsKdId )
							throws Exception {
				Map<String, Object> params = new HashMap<String, Object>();
				params.put("EQ_libId", EQ_libId);
				params.put("EQ_howDetailsKdId", EQ_howDetailsKdId);
				params.put("LIKE_alias",request.getParameter("LIKE_alias")==null?"":request.getParameter("LIKE_alias"));
				params.put("EQ_grade",request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));//年级
				params.put("EQ_semester",request.getParameter("EQ_semester")==null?"":request.getParameter("EQ_semester"));//学期
				params.put("EQ_banben",request.getParameter("EQ_banben")==null?"":request.getParameter("EQ_banben"));//版本
				params.put("EQ_stat",EQ_stat);//单元
				params.put("LIKE_id",request.getParameter("LIKE_id")==null?"":request.getParameter("LIKE_id"));
				params.put("EQ_courseName", request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
				Page<Map<String, Object>>  page= zuoybKnowHowDetailsSortService.getZuoybKnowKdSort(params, initPage(pageNo,pageSize));
				params.put("EQ_howId", EQ_howId);
				params.put("EQ_howDetailsId", EQ_howDetailsId);
				SplitPage sp = new SplitPage();
				sp.setAction(request.getRequestURI().toString());
				sp.setPageNo(pageNo);
				sp.setPageSize(pageSize);
				sp.setParams(params);
				sp.setRowCnt((int) page.getTotalElements());
				model.addAttribute("list", page.getContent());
				model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
				model.addAttribute("page", sp);
				model.addAttribute("search", params);
				model.addAttribute("grade", sortService.getParamValByCode("grade"));
				model.addAttribute("versions", SystemResourceLocator.getVersionList());
				return "sys/zuoyb/knowHowDetailKdVersionList";
			}
			
			@RequestMapping("/knowHowDetailKdVersionAdd")
			public String knowHowDetailKdVersionAdd(Model model,@RequestParam( defaultValue = "0")String id,String howId,
					String howDetailsId,String howDetailsKdId) throws Exception {
				ZuoybKnowHowDetailsSort  sort= zuoybKnowHowDetailsSortService.getById(id);
				if(sort ==null){
					sort = new  ZuoybKnowHowDetailsSort();
					sort.setLibId("SSJ");
					sort.setHowId(howId);
					sort.setHowDetailsId(howDetailsId);
					sort.setStat(3);
					sort.setHowDetailsKdId(howDetailsKdId);
					ZuoybKnowHow  zuoybKnowHow=	zuoybKnowHowService.getById(howId);
					sort.setCourseName(zuoybKnowHow.getCourseName());
				}
				model.addAttribute("how", sort);
				model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
				model.addAttribute("versions", SystemResourceLocator.getVersionList());
				return "sys/zuoyb/knowHowDetailKdVersionAdd";
			}	
			@RequestMapping("/knowHowVersionAdd")
			public String knowHowVersionAdd(Model model,@RequestParam( defaultValue = "0")String id,String howId) throws Exception {
				ZuoybKnowHowDetailsSort  sort= zuoybKnowHowDetailsSortService.getById(id);
				if(sort ==null){
					sort = new  ZuoybKnowHowDetailsSort();
					sort.setLibId("SSJ");
					sort.setHowId(howId);
					ZuoybKnowHow  zuoybKnowHow=	zuoybKnowHowService.getById(howId);
					sort.setCourseName(zuoybKnowHow.getCourseName());
					sort.setStat(1);
				}
				model.addAttribute("how", sort);
				model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
				model.addAttribute("versions", SystemResourceLocator.getVersionList());
				return "sys/zuoyb/knowHowVersionAdd";
			}	
			
		/**
		* 创建人：ZhangCaibao 
		* 2017年9月27日 下午3:15:35 
		* @String
		 */
		@RequestMapping("/knowHowDetailList")
		public String knowHowDetailList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,
				@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
				 String EQ_howId)
						throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_howId", EQ_howId);
			params.put("EQ_libId", EQ_libId);
			params.put("LIKE_name",request.getParameter("LIKE_name")==null?"":request.getParameter("LIKE_name"));
			params.put("LIKE_module",request.getParameter("LIKE_module")==null?"":request.getParameter("LIKE_module"));
			params.put("EQ_grade", request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));
			params.put("semester", request.getParameter("semester")==null?"":request.getParameter("semester"));
			params.put("banben", request.getParameter("banben")==null?"":request.getParameter("banben"));
			params.put("EQ_courseName", request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));

			params.put("LIKE_id", request.getParameter("LIKE_id")==null?"":request.getParameter("LIKE_id"));

			Page<Map<String, Object>> page= zuoybKnowHowDetailsService.getZuoybKnowHowDetails(params, initPage(pageNo,pageSize));
			SplitPage sp = new SplitPage();
			sp.setAction(request.getRequestURI().toString());
			sp.setPageNo(pageNo);
			sp.setPageSize(pageSize);
			sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
			model.addAttribute("grade", sortService.getParamValByCode("grade"));
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/knowHowDetailList";
		}
		@RequestMapping("/getHowDetailsNameList")
		public String getHowDetailsNameList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,
				@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
				String howdetailsId,String sortId)
						throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_libId", EQ_libId);
			params.put("LIKE_name",request.getParameter("LIKE_name")==null?"":request.getParameter("LIKE_name"));
			params.put("LIKE_module",request.getParameter("LIKE_module")==null?"":request.getParameter("LIKE_module"));
			params.put("EQ_grade", request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));
			params.put("semester", request.getParameter("semester")==null?"":request.getParameter("semester"));
			params.put("banben", request.getParameter("banben")==null?"":request.getParameter("banben"));
			params.put("EQ_courseName",request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
			Page<Map<String, Object>> page= zuoybKnowHowDetailsService.getZuoybKnowHowDetails(params, initPage(pageNo,pageSize));
			params.put("howdetailsId",request.getParameter("howdetailsId")==null?"":request.getParameter("howdetailsId"));
			params.put("sortId",request.getParameter("sortId")==null?"":request.getParameter("sortId"));
			SplitPage sp = new SplitPage();
			sp.setAction(request.getRequestURI().toString());
			sp.setPageNo(pageNo);
			sp.setPageSize(pageSize);
			sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
			model.addAttribute("grade", sortService.getParamValByCode("grade"));
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/getHowDetailsNameList";
		}
		@RequestMapping("/getHowDetailsKdNameList")
		public String getHowDetailsKdNameList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,
				@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,String  EQ_howDetailsKdId,
				String howdetailsId,String sortId)
						throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_libId", EQ_libId);
			params.put("LIKE_alias",request.getParameter("LIKE_alias")==null?"":request.getParameter("LIKE_alias"));
			params.put("EQ_grade",request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));//年级
			params.put("EQ_semester",request.getParameter("EQ_semester")==null?"":request.getParameter("EQ_semester"));//学期
			params.put("EQ_banben",request.getParameter("EQ_banben")==null?"":request.getParameter("EQ_banben"));//版本
			params.put("EQ_courseName", request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
			Page<Map<String, Object>>  page= zuoybKnowHowDetailsSortService.getZuoybKnowKdSort(params, initPage(pageNo,pageSize));
			params.put("EQ_howDetailsKdId", EQ_howDetailsKdId);
			params.put("beforeHowdetailsKdId",request.getParameter("beforeHowdetailsKdId")==null?"":request.getParameter("beforeHowdetailsKdId"));
			params.put("sortId",request.getParameter("sortId")==null?"":request.getParameter("sortId"));
			SplitPage sp = new SplitPage();
			sp.setAction(request.getRequestURI().toString());
			sp.setPageNo(pageNo);
			sp.setPageSize(pageSize);
			sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
			model.addAttribute("grade", sortService.getParamValByCode("grade"));
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/getHowDetailsKdNameList";
		}
	
		@RequestMapping("/knowHowDetailSortList")
		public String knowHowDetailSortList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,
				@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
				@RequestParam(required = false, defaultValue = "2") String EQ_stat,
				String EQ_howId,String EQ_howDetailsId)
						throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_howDetailsId", EQ_howDetailsId);
			params.put("EQ_howId", EQ_howId);
			params.put("EQ_libId", EQ_libId);
			params.put("LIKE_alias",request.getParameter("LIKE_alias")==null?"":request.getParameter("LIKE_alias"));
			params.put("EQ_grade",request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));//年级
			params.put("EQ_semester",request.getParameter("EQ_semester")==null?"":request.getParameter("EQ_semester"));//学期
			params.put("EQ_banben",request.getParameter("EQ_banben")==null?"":request.getParameter("EQ_banben"));//版本

			params.put("LIKE_id",request.getParameter("LIKE_id")==null?"":request.getParameter("LIKE_id"));//版本

			params.put("EQ_stat",EQ_stat);//单元
			Page<Map<String, Object>>  page= zuoybKnowHowDetailsSortService.getZuoybKnowSort(params, initPage(pageNo,pageSize));
			params.put("EQ_courseName", request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
			SplitPage sp = new SplitPage();
			sp.setAction(request.getRequestURI().toString());
			sp.setPageNo(pageNo);
			sp.setPageSize(pageSize);
			sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
			model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/knowHowDetailSortList";
		}
		@RequestMapping("/knowHowDetailKdList")
		public String knowHowDetailKdList(Model model,
				@RequestParam(required = false, defaultValue = "10") int pageSize,
				@RequestParam(required = false, defaultValue = "1") int pageNo,
				@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
				String EQ_howId,String EQ_howDetailsId)
						throws Exception {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("EQ_howId", EQ_howId);
			params.put("EQ_libId", EQ_libId);
			params.put("EQ_howDetailsId", EQ_howDetailsId);
			params.put("LIKE_name",request.getParameter("LIKE_name")==null?"":request.getParameter("LIKE_name"));
			params.put("EQ_grade", request.getParameter("EQ_grade")==null?"":request.getParameter("EQ_grade"));
			params.put("semester", request.getParameter("semester")==null?"":request.getParameter("semester"));
			params.put("banben", request.getParameter("banben")==null?"":request.getParameter("banben"));
			params.put("LIKE_id",request.getParameter("LIKE_id")==null?"":request.getParameter("LIKE_id"));
			params.put("EQ_courseName", request.getParameter("EQ_courseName")==null?"":request.getParameter("EQ_courseName"));
			Page<Map<String, Object>> page=zuoybKnowHowDetailsKdService.getZuoybKnowHowDetailsKd(params, initPage(pageNo,pageSize));
			SplitPage sp = new SplitPage();
			sp.setAction(request.getRequestURI().toString());
			sp.setPageNo(pageNo);
			sp.setPageSize(pageSize);
			sp.setParams(params);
			sp.setRowCnt((int) page.getTotalElements());
			model.addAttribute("list", page.getContent());
			model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
			model.addAttribute("page", sp);
			model.addAttribute("search", params);
			model.addAttribute("grade", sortService.getParamValByCode("grade"));
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/knowHowDetailKdList";
		}
		/**
		 * 新增作业知识点基础数据
		 * @param model
		 * @param id
		 * @param libId
		 * @return
		 * @throws Exception
		 * 创建人：ZhangCaibao 
		 * 2017年9月26日 下午3:10:39 
		 * @String
		 */
		@RequestMapping("/knowHowDetailAdd")
		public String knowHowDetailAdd(Model model,@RequestParam( defaultValue = "0")String id,
				String  libId,String howId) throws Exception {
			ZuoybKnowHowDetails  how= zuoybKnowHowDetailsService.getById(id);
			if(how ==null){
				how = new  ZuoybKnowHowDetails();
				how.setLibId(libId);
				how.setHowId(howId);
				how.setIsHot(0);
				ZuoybKnowHow  knowHow=	zuoybKnowHowService.getById(howId);
				how.setIsZt(knowHow.getIsZt());
				how.setMemorize(0);
				how.setUnderstanding(0);
				how.setApply(0);
				 model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
			}
			model.addAttribute("zyb_topic", sortService.getParamValByCode("zyb_topic"));
			model.addAttribute("how", how);
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/knowHowDetailAdd";
		}	
		@RequestMapping("/knowHowDetailSortAdd")
		public String knowHowDetailSortAdd(Model model,@RequestParam( defaultValue = "0")String id,
				String  libId,String howId,String howDetailsId) throws Exception {
			ZuoybKnowHowDetailsSort  sort= zuoybKnowHowDetailsSortService.getById(id);
			if(sort ==null){
				sort = new  ZuoybKnowHowDetailsSort();
				sort.setLibId(libId);
				sort.setHowId(howId);
				sort.setHowDetailsId(howDetailsId);
				sort.setStat(2);
				ZuoybKnowHow  zuoybKnowHow=	zuoybKnowHowService.getById(howId);
				sort.setCourseName(zuoybKnowHow.getCourseName());
			}
			model.addAttribute("how", sort);
			model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/knowHowDetailSortAdd";
		}	
		/** 
		 * 作业知识点基础数据保存
		 * @param content
		 * @return
		 * 创建人：ZhangCaibao 
		 * 2017年7月5日 上午10:40:51 
		 * @Response
		 */
		@RequestMapping(value = "/knowHowDetailSave", method = RequestMethod.POST)
		@ResponseBody
		public Response knowHowDetailSave(ZuoybKnowHowDetails how) {
			Response response = new Response();
			how.setCreateTime(new Date());
			how = zuoybKnowHowDetailsService.save(how);

			String[] version = how.getVersion();
			if (version != null && version.length > 0) {
				String grade = "";
				List<Sort> list = sortService.getParamValByCode("grade");
				Integer gradeNum = how.getGradeNum();
				for (Sort sort : list) {
					if (sort.getAliases().equals(gradeNum.toString())) {
						grade = sort.getName();
						break;
					}
				}
				ZuoybKnowHow zuoybKnowHow = zuoybKnowHowService.getById(how.getHowId());
				for (String string : version) {
					ZuoybKnowHowDetailsSort howsort = new ZuoybKnowHowDetailsSort();
					howsort.setCreateTime(new Date());
					howsort.setHowDetailsId(how.getId());
					howsort.setType(Integer.parseInt(string));
					howsort.setHowId(how.getHowId());
					howsort.setCourseName(zuoybKnowHow.getCourseName());
					howsort.setNum(how.getNum());
					howsort.setAlias(how.getName());
					howsort.setLibId(how.getLibId());
					howsort.setStat(2);
					howsort.setGrade(grade);
					howsort.setGradeNum(how.getGradeNum());
					howsort.setSemester(how.getSemester());

                    howsort.setMemorize(how.getMemorize());
                    howsort.setUnderstanding(how.getUnderstanding());
                    howsort.setApply(how.getApply());
                    howsort.setModule(how.getModule());
                    howsort.setTwoModule(how.getTwoModule());
                    howsort.setJxmb(how.getJxmb());
                    howsort.setZdbx(how.getZdbx());
                    howsort.setYdsl(how.getYdsl());

                    howsort=zuoybKnowHowDetailsSortService.save(howsort);
				}
			}

			response.success("添加成功");
			return response;
		}
		@RequestMapping("/knowHowDetailKdAdd")
		public String knowHowDetailKdAdd(Model model,@RequestParam( defaultValue = "0")String id,
				String howId,String howDetailsId) throws Exception {
			ZuoybKnowHowDetailsKd  kd= zuoybKnowHowDetailsKdService.getById(id);
			if(kd ==null){
				kd = new  ZuoybKnowHowDetailsKd();
				kd.setHowId(howId);
				kd.setHowDetailsId(howDetailsId);
				model.addAttribute("grade", sortService.getParamValByCode("grade"));//年级
				 
			}
			model.addAttribute("how", kd);
			model.addAttribute("kd_level", sortService.getParamValByCode("kd_level"));
			model.addAttribute("versions", SystemResourceLocator.getVersionList());
			return "sys/zuoyb/knowHowDetailKdAdd";
		}	
		@RequestMapping(value = "/knowHowDetailSortSave", method = RequestMethod.POST)
		@ResponseBody
		public Response knowHowDetailSortSave(  ZuoybKnowHowDetailsSort  how) {
			Response response = new Response();
			how.setCreateTime(new Date());

			List<Sort> list=sortService.getParamValByCode("grade");
			Integer gradeNum = how.getGradeNum();
			for (Sort sort : list) {
				if(sort.getAliases().equals(gradeNum.toString())){
					how.setGrade(sort.getName());
					break;
				}
			}
			if(StringUtil.isEmpty(how.getId())){
				if(2==how.getStat()){
					ZuoybKnowHowDetails howDetails =  zuoybKnowHowDetailsService.getById(how.getHowDetailsId());
					if(howDetails!=null){
						if(StringUtil.isEmpty(how.getMemorize())) how.setMemorize(howDetails.getMemorize());
						if(StringUtil.isEmpty(how.getUnderstanding())) how.setUnderstanding(howDetails.getUnderstanding());
						if(StringUtil.isEmpty(how.getApply())) how.setApply(howDetails.getApply());
						if(StringUtil.isEmpty(how.getModule()))how.setModule(howDetails.getModule());
						if(StringUtil.isEmpty(how.getTwoModule()))how.setTwoModule(howDetails.getTwoModule());
						if(StringUtil.isEmpty(how.getJxmb()))how.setJxmb(howDetails.getJxmb());
						if(StringUtil.isEmpty(how.getZdbx()))how.setZdbx(howDetails.getZdbx());
						if(StringUtil.isEmpty(how.getYdsl()))how.setYdsl(howDetails.getYdsl());
					}
				}



            }
			zuoybKnowHowDetailsSortService.save(how);
			response.success("添加成功");
			return response;
		}
		@RequestMapping(value = "/updateBeforeKd", method = RequestMethod.POST)
		@ResponseBody
		public Response updateBeforeKd( String beforeKdId,String sortId) {
			Response response = new Response();
			zuoybKnowHowDetailsSortService.updateBeforeKd(beforeKdId, sortId);
			response.success("添加成功");
			return response;
		}
		@RequestMapping(value = "/knowHowDetailKdSave", method = RequestMethod.POST)
		@ResponseBody
		public Response knowHowDetailKdSave(  ZuoybKnowHowDetailsKd  how) {
			Response response = new Response();
			how.setCreateTime(new Date());
			how = zuoybKnowHowDetailsKdService.save(how);
			

			 String [] version = how.getVersion();
			 if(version!=null && version.length>0){
				    String grade = "";
				    List<Sort> list=sortService.getParamValByCode("grade");
					Integer gradeNum = how.getGradeNum();
					for (Sort sort : list) {
						if(sort.getAliases().equals(gradeNum.toString())){
							grade =sort.getName();
							break;
						}
					}
				ZuoybKnowHow  zuoybKnowHow=	zuoybKnowHowService.getById(how.getHowId());
				 for (String string : version) {
					 ZuoybKnowHowDetailsSort  howsort = new ZuoybKnowHowDetailsSort();
					 howsort.setCreateTime(new Date());
					 howsort.setHowDetailsId(how.getHowDetailsId());
					 howsort.setHowDetailsKdId(how.getId());
					 howsort.setType(Integer.parseInt(string));
					 howsort.setHowId(how.getHowId());
					 howsort.setCourseName(zuoybKnowHow.getCourseName());
					 howsort.setNum(how.getNum());
					 howsort.setAlias(how.getName());
					 howsort.setLibId(zuoybKnowHow.getLibId());
					 howsort.setStat(3);
					 howsort.setGrade(grade);
					 howsort.setGradeNum(how.getGradeNum());
					 howsort.setSemester(how.getSemester());
					 howsort=zuoybKnowHowDetailsSortService.save(howsort);
				}
			 }
			 
			response.success("添加成功");
			return response;
		}


		@RequestMapping(value = "/knowHowDetailSortDelete", method = RequestMethod.POST)
		@ResponseBody
		public Response knowHowDetailSortDelete( 
				@RequestParam(value = "id")String id) {
			Response response = new Response();
			zuoybKnowHowDetailsSortService.delete(id);
			response.success("删除成功");
			return response;
		}
		
		 @RequestMapping(value = "/updateKnowHowDetailNum", method = RequestMethod.POST)
		 @ResponseBody
		 public Response updateKnowHowDetailNum( String id,Integer  num){
			 Response response = new  Response();
			 zuoybKnowHowDetailsService.updateKnowHowDetailNum(id, num);
			 response.success();
			 return response;
		 }
		 @RequestMapping(value = "/updateKnowHowDetailSortNum", method = RequestMethod.POST)
		 @ResponseBody
		 public Response updateKnowHowDetailSortNum( String id,Integer  num){
			 Response response = new  Response();
			 zuoybKnowHowDetailsSortService.updateKnowHowDetailSortNum(id, num);
			 response.success();
			 return response;
		 }
		 @RequestMapping(value = "/updateKnowHowDetailKdNum", method = RequestMethod.POST)
		 @ResponseBody
		 public Response updateKnowHowDetailKdNum( String id,Integer  num){
			 Response response = new  Response();
			 zuoybKnowHowDetailsKdService.updateKnowHowDetailKdNum(id, num);
			 response.success();
			 return response;
		 }
		 
	 /**
		 * 新增作业知识点基础数据
		* 2017年9月26日 下午3:10:39 
		* @String
		 */
		  @RequestMapping("/knowHowImport")
		  public String knowHowImport(Model model,String  libId) throws Exception {
		     model.addAttribute("libId", libId);
			 return "sys/zuoyb/knowHowImport";
		 }
		  @RequestMapping("/knowHowKdImport")
		  public String knowHowKdImport(Model model,String  libId) throws Exception {
		     model.addAttribute("libId", libId);
			 return "sys/zuoyb/knowHowKdImport";
		 }
		  @RequestMapping(value = "/knowHowDetilsKdImportSave", method = RequestMethod.POST)
			@ResponseBody
			public Response knowHowDetilsKdImportSave(HttpServletRequest request,HttpServletResponse response2,String libId) throws Exception{
				Response response = new Response();
				XSSFWorkbook workbook = null; 
				try {
					MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
					MultipartFile file = multipartRequest.getFile("file");  
					workbook = new XSSFWorkbook(file.getInputStream());
					XSSFSheet sheet = workbook.getSheetAt(0);   //读取第一个工作簿  
					Row row = null;  
					
					int startReadLine = 1;
					int lastRow = -1;
					int sortLastRow =-1;
					for(int i=startReadLine; i<=sheet.getLastRowNum(); i++) {  
						row = sheet.getRow(i);
						int x = 0;
						ZuoybKnowHowDetailsKd kd =new  ZuoybKnowHowDetailsKd();
						for(Cell c : row) {  
							x = c.getColumnIndex();
							c.setCellType(Cell.CELL_TYPE_STRING);
							//判断是否具有合并单元格  
							String rs = c.getRichStringCellValue().toString().trim();
							logger.info("rs-->"+rs);
							if(x == 0){
								if(rs!=null&&!"".equals(rs))
									kd.setHowId(rs);
							}else if (x==1){
								if(rs!=null&&!"".equals(rs))
									kd.setHowDetailsId(rs);
							}else if (x==2){
								if(rs!=null&&!"".equals(rs))
									kd.setId(rs);
							}else if (x==3){
								if(rs!=null&&!"".equals(rs))
									kd.setName(rs);
							}else if (x==4){
								if(rs!=null&&!"".equals(rs))
									kd.setYdsl(rs);
							}else if (x==5){
								if(rs!=null&&!"".equals(rs))
									kd.setImg(rs);
							}else if (x==6){
								if(rs!=null&&!"".equals(rs))
									kd.setLabel(rs);
							}else if (x==7){
								if(rs!=null&&!"".equals(rs))
									kd.setLevel(rs);
							}else if (x==6){
								if(rs!=null&&!"".equals(rs)){
									kd.setNum(Integer.parseInt(rs));
								}
								
								logger.info("lastRow-->"+lastRow);
								logger.info("sortLastRow-->"+sortLastRow);
								kd.setCreateTime(new Date());
								kd=zuoybKnowHowDetailsKdService.save(kd);
								
							}
						}    
					}  
					workbook.close();
				} catch (FileNotFoundException e) {
					
					e.printStackTrace();
				} catch (IOException e) {
					
					e.printStackTrace();
				}
				response.success("添加成功");
				return response;
			}
			  
		@RequestMapping(value = "/knowHowImportSave", method = RequestMethod.POST)
		@ResponseBody
		public Response knowHowImportSave(HttpServletRequest request,HttpServletResponse response2,String libId) throws Exception{
			 Response response = new Response();
			 XSSFWorkbook workbook = null; 
			 try {
				MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
				MultipartFile file = multipartRequest.getFile("file");  
				workbook = new XSSFWorkbook(file.getInputStream());
				XSSFSheet sheet = workbook.getSheetAt(0);   //读取第一个工作簿  
		        Row row = null;  
		        
		        int startReadLine = 1;
		        int lastRow = -1;
		        int sortLastRow =-1;
		        List<ZuoybKnowHowDetails> detailList = new ArrayList<ZuoybKnowHowDetails>();
		        List<ZuoybKnowHowDetailsSort> detailSortList = new ArrayList<ZuoybKnowHowDetailsSort>();
		        for(int i=startReadLine; i<=sheet.getLastRowNum(); i++) {  
		        	ZuoybKnowHow knowHow = new ZuoybKnowHow();
		            row = sheet.getRow(i);
		            int x = 0;
		            ZuoybKnowHowDetails detail = new ZuoybKnowHowDetails();
		            ZuoybKnowHowDetailsSort sort =new  ZuoybKnowHowDetailsSort();
		            for(Cell c : row) {  
		            	x = c.getColumnIndex();
		                c.setCellType(Cell.CELL_TYPE_STRING);
		                Map<String, Integer> isMerge =ReadMergeRegionExcel.isMergedRegion(sheet, i, c.getColumnIndex());
		                
		                //判断是否具有合并单元格  
		                String rs = "";
		                if(isMerge != null ) {  
		                    rs = ReadMergeRegionExcel.getMergedRegionValue(sheet, row.getRowNum(), c.getColumnIndex()).trim(); 
		                    if(c.getColumnIndex() == 4){
		                    	lastRow = isMerge.get("lastRow");
		                    	logger.info("lastRow-->"+lastRow);
		                    }
		                    if(c.getColumnIndex() == 16){
		                    	sortLastRow = isMerge.get("lastRow");
		                    	logger.info("lastRow-->"+lastRow);
		                    }
		                    
		                }else {  
		                	rs = c.getRichStringCellValue().toString().trim();
		                    if(c.getColumnIndex() == 4){
		                    	lastRow = i;
		                    }
		                    if(c.getColumnIndex() == 16){
		                    	sortLastRow = i;
		                    }
		                }  
		                logger.info("rs-->"+rs);
		                if(x == 0){
		                	if(rs!=null&&!"".equals(rs))
		                	knowHow.setCourseName(rs);//课程
		                	sort.setCourseName(rs);//课程
		                }else if (x==1){
		                	if(rs!=null&&!"".equals(rs))
		                		knowHow.setName(rs);//单元
		                }else if (x==2){
		                	if(rs!=null&&!"".equals(rs)){
		                		knowHow.setId(rs);//id
		                	}
			                	
		                }else if (x==3){
		                	//logger.info("getName-->"+knowHow.getName());
		                	if(rs!=null&&!"".equals(rs)){
		                		knowHow.setNum(Integer.parseInt(rs));//单元序号
		                	}
		                	if(knowHow.getId() ==null){
		                		ZuoybKnowHow oldKnowHow= new   ZuoybKnowHow();
		                		if(knowHow.getNum()==null){
		                			oldKnowHow=zuoybKnowHowService.findByNameAndLibIdAndCourseName(knowHow.getName(), libId, 
		                					knowHow.getCourseName());
		                		}else{
		                			oldKnowHow=zuoybKnowHowService.findByNameAndLibIdAndCourseName(knowHow.getName(), libId, 
		                					knowHow.getCourseName(), knowHow.getNum());
		                		}
		                		if(oldKnowHow!=null){
		                			BeanUtils.copyProperties(knowHow, oldKnowHow);
		                			logger.info("oldKnowHow.Id-->"+oldKnowHow.getId());
		                		}
		                	}
		                }else if (x==4){
		                	if(rs!=null&&!"".equals(rs))
		                		knowHow.setModule(rs);//模块
		                	
		                }else if (x==5){
		                	detail.setName(rs);//知识点
		                }else if (x==6){
		                	if(rs !=null&&!"".equals(rs)){
		                		detail.setId(rs);
		                	}
	                		
		                }else if (x==7){
		                	if(knowHow.getId()!=null&&detail.getId()==null){
		                		ZuoybKnowHowDetails oldHowDetails =zuoybKnowHowDetailsService.findByHowIdAndName(knowHow.getId(), detail.getName());
		                		if(oldHowDetails!=null){
		                			BeanUtils.copyProperties(detail, oldHowDetails);
		                			logger.info("oldHowDetails.Id-->"+oldHowDetails.getId());
		                		}
		                	}
		                	if(rs!=null&&!"".equals(rs))
		                		detail.setModule(rs);
		                	
		                }else if (x==8){

		                	if(rs!=null&&!"".equals(rs))
		                		detail.setJxmb(rs);  //教学目标
		                	
		                }else if (x==9){
		                	if(rs!=null&&!"".equals(rs))
		                		detail.setZdbx(rs);//重点标识
		                	
		                }else if (x==10){
		                	if(rs!=null&&!"".equals(rs))
		                		detail.setYdsl(rs); //要点梳理
		                }else if (x==11){
		                	if(rs !=null&&!"".equals(rs)){
		                		detail.setImg(rs);//要点梳理图片
		                	}	
		                }else if (x==12){
		                	if(rs!=null&&!"".equals(rs))
		                		detail.setTwoModule(rs);//二级模块
		                }else if (x==13){
		                	if(rs!=null&&!"".equals(rs))
		                		detail.setBeforeName(rs); //前知识点
		                	
		                }else if (x==14){
		                	if(rs!=null&&!"".equals(rs))
		                		detail.setAfterName(rs); //后知识点
		                }else if (x==15){
		                	if(rs !=null&&!"".equals(rs))
		                		detail.setType(rs);//题目类型
		                
		                }else if (x==16){
		                	if(rs !=null&&!"".equals(rs))
		                		detail.setIsHot(Integer.parseInt(rs));//重点章节
		                }else if (x==17){
		                	if(rs !=null&&!"".equals(rs))
		                		detail.setMemorize(Integer.parseInt(rs)); ////识记
		                	
		                }else if (x==18){
		                	if(rs !=null&&!"".equals(rs))
		                		detail.setUnderstanding(Integer.parseInt(rs));////理解
		                }else if (x==19){
		                	if(rs !=null&&!"".equals(rs))
		                		detail.setApply(Integer.parseInt(rs));//应用
		                	
		                }else if (x==20){
		                	if(rs !=null&&!"".equals(rs)){
		                		detail.setDuration(rs);//时长
		                	}
		                	
		                }else if (x==21){
		                	if(rs !=null&&!"".equals(rs)){
		                		detail.setNum(Integer.parseInt(rs));//知识点排序
		                	}
		                	
		                }else if (x==22){
		                	if(rs !=null&&!"".equals(rs)){
		                		sort.setId(rs);
		                	}
		                	
		                }else if (x==23){
		                	if(rs !=null&&!"".equals(rs)){
		                		sort.setSemester(Integer.parseInt(rs));//1上学期，2下学期
		                	}
		                	
		                	
		                	
		                }else if (x==24){
		                	if(rs !=null&&!"".equals(rs)){
		                		sort.setNum(Integer.parseInt(rs));//排序
		                	}
		                	
		                }else if (x==25){
		                	if(rs !=null&&!"".equals(rs)){
		                		sort.setGradeNum(Integer.parseInt(rs));//年级
		                	}
		                	
		                }else if (x==26){
		                	
		                	if(rs !=null&&!"".equals(rs)){
		                		sort.setType(Integer.parseInt(rs));//版本
		                		if(detail.getId()!=null){
		                			ZuoybKnowHowDetailsSort oldSort =zuoybKnowHowDetailsSortService.findByHowDetailsIdAndType(detail.getId(), Integer.parseInt(rs));
		                					if(oldSort!=null){
		                						if(sort.getSemester()!=null)oldSort.setSemester(sort.getSemester());
		                						if(sort.getNum()!=null)oldSort.setNum(sort.getNum());
		                						if(sort.getGradeNum()!=null)oldSort.setGradeNum(sort.getGradeNum());
		                						BeanUtils.copyProperties(sort, oldSort);
		                						logger.info("oldSort.Id-->"+oldSort.getId());
		                					}
		                		}
		                	}
		                	detail.setCreateTime(new Date());
		                	detail.setLibId(libId);
		                	detail.setHowId(knowHow.getId());
		                	logger.info("detail-->"+detail);
		                	logger.info("detail-->"+JSON.toJSONString(detail));
		                	List<ZuoybKnowHowDetails> olddetailList = detailList;
		                	if(detailList.size()>0){
		                		for(ZuoybKnowHowDetails zuoybKnowHowDetails :olddetailList){
		                			if(!zuoybKnowHowDetails.equals(detail)){
		                				detailList.add(detail);
		                			}
		                		}
		                	}else{
		                		detailList.add(detail);
		                	}
		                	detailList = olddetailList;
		                	detailSortList.add(sort);
		                	logger.info("lastRow-->"+lastRow);
		                	logger.info("sortLastRow-->"+sortLastRow);
		                	knowHow.setCreateTime(new Date());
		                	knowHow.setLibId(libId);
		                	if(i == sortLastRow){
		                		
		                		knowHow = zuoybKnowHowService.save(knowHow);
		                		for(ZuoybKnowHowDetails detail2 :detailList){
		                			if(detail2.getHowId()==null){
		                				detail2.setHowId(knowHow.getId());
		                			}
		                			detail2=zuoybKnowHowDetailsService.save(detail2);
		                			for (ZuoybKnowHowDetailsSort zuoybKnowHowDetailsSort : detailSortList) {
		                				zuoybKnowHowDetailsSort.setHowDetailsId(detail2.getId());
		                				zuoybKnowHowDetailsSort.setHowId(knowHow.getId());
		                				zuoybKnowHowDetailsSort.setLibId(libId);
		                				zuoybKnowHowDetailsSort.setCreateTime(new Date());
		                				//zuoybKnowHowDetailsSort.setGrade(grade);
		                				zuoybKnowHowDetailsSortService.save(zuoybKnowHowDetailsSort);
									}
		                			detailSortList.clear();
		                		}
		                		detailList.clear();
		                		knowHow = new ZuoybKnowHow();
		                	}
		                	
		                }
		            }    
		        }  
		        workbook.close();
			} catch (FileNotFoundException e) {
				
				e.printStackTrace();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
			 response.success("添加成功");
			 return response;
		}
		
	@RequestMapping(value = "/exportKnowExcel", method = RequestMethod.POST)
	@ResponseBody
	public void exportKnowExcel(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId) throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		
		StringBuffer fileName =new StringBuffer("知识点");
		if(request.getParameter("EQ_courseName") != null){
			params.put("EQ_courseName",  request.getParameter("EQ_courseName"));
			fileName.append(request.getParameter("EQ_courseName"));
		}
		if(request.getParameter("EQ_grade") != null){
			params.put("EQ_grade",  request.getParameter("EQ_grade"));
			fileName.append(request.getParameter("EQ_grade")+"年级");
		}
		String semester= request.getParameter("semester");
		if(semester != null && !"".equals(semester)){
			params.put("semester",  request.getParameter("semester"));//学期
			fileName.append("1".equals(semester)?"上学期":"下学期");
		}
		
		params.put("EQ_libId", EQ_libId);
		params.put("LIKE_name", request.getParameter("LIKE_name") == null ? "" : request.getParameter("LIKE_name"));
		params.put("banben", request.getParameter("banben") == null ? "" : request.getParameter("banben"));
		ServletOutputStream os = null;
		try {
			os = response.getOutputStream(); // 获得输出流
			response.reset(); // 清空输出流

			String  filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";  
			int rownum = 1; // 添加的起始行
           

			ClassPathResource classPathResource = new ClassPathResource("/excel/report/report7.xlsx");
			XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
			response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
			// response.setContentType("application/msexcel"); //定义输出类型
			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
			response.setCharacterEncoding("utf-8");
			XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
			XSSFRow row;
			XSSFCell cell = null;
			XSSFCellStyle style = this.getxStyle(workbook);
			List<Map<String, Object>> list = zuoybKnowHowDetailsService.getKonwDetail(params);
			int endRow = rownum;
			int startRow = rownum;
			
			int idnum =6;
			int detailnum =23;
			int detailStartRow =rownum ;
			int detailEndRow = rownum;
			for (int i = 0; i < list.size(); i++) {
				row = sheet.createRow(rownum);
				int j = 0;
				myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("module")!=null?list.get(i).get("module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("how_create_time")!=null?list.get(i).get("how_create_time").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("detail_name")!=null?list.get(i).get("detail_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_id")!=null?list.get(i).get("detail_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("t11_module")!=null?list.get(i).get("t11_module").toString():"", row, cell, style); // 列1
				
				myCreateCellx(j++, list.get(i).get("jxmb")!=null?list.get(i).get("jxmb").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("zdbx")!=null?list.get(i).get("zdbx").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("ydsl")!=null?list.get(i).get("ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("img")!=null?list.get(i).get("img").toString():"", row, cell, style); // 列1
				
				myCreateCellx(j++, list.get(i).get("two_module")!=null?list.get(i).get("two_module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("before_name")!=null?list.get(i).get("before_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("after_name")!=null?list.get(i).get("after_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("type")!=null?list.get(i).get("type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("is_hot")!=null?list.get(i).get("is_hot").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("memorize")!=null?list.get(i).get("memorize").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("understanding")!=null?list.get(i).get("understanding").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("apply")!=null?list.get(i).get("apply").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("duration")!=null?list.get(i).get("duration").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_num")!=null?list.get(i).get("detail_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_create_time")!=null?list.get(i).get("detail_create_time").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
				if (i > 0) {
					
					logger.info("list.get(i).get(\"detail_id\")-->"+list.get(i).get("detail_id"));
					logger.info("list.get(i-1).get(\"detail_id\")-->"+list.get(i-1).get("detail_id"));
					if (list.get(i).get("detail_id")!=null&&list.get(i).get("detail_id").toString().equals(list.get(i - 1).get("detail_id").toString())) {
						detailEndRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						
					} else {
						if (detailStartRow != detailEndRow) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						
						detailStartRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						detailEndRow = rownum;// 合并结束行同合并开始行
					}
					
					
					if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
						endRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}

					} else {
						if (startRow != endRow) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						startRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						endRow = rownum;// 合并结束行同合并开始行
					}
					
			
					
					
					
					
				}
				rownum++;
			}
			 workbook.write(os);  
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(os != null){
	    		try {
					os.flush();
					os.close(); 
				} catch (IOException e) {
					e.printStackTrace();
				}  
    	   }
		}
	}
	/**
	 * 导出考点
	* @param request
	* @param response
	* @param EQ_libId
	* @throws Exception
	* 创建人：ZhangCaibao 
	* 2018年6月10日 上午11:08:26 
	* @void
	 */
	@RequestMapping(value = "/exportKnowKdExcel", method = RequestMethod.POST)
	@ResponseBody
	public void exportKnowKdExcel(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId) throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		StringBuffer fileName =new StringBuffer("考点");
		if(request.getParameter("EQ_courseName") != null){
			params.put("EQ_courseName",  request.getParameter("EQ_courseName"));
			fileName.append(request.getParameter("EQ_courseName"));
		}
		if(request.getParameter("EQ_grade") != null){
			params.put("EQ_grade",  request.getParameter("EQ_grade"));
			fileName.append(request.getParameter("EQ_grade")+"年级");
		}
		String semester= request.getParameter("semester");
		if(semester != null && !"".equals(semester)){
			params.put("semester",  request.getParameter("semester"));//学期
			fileName.append("1".equals(semester)?"上学期":"下学期");
		}
		params.put("EQ_libId", EQ_libId);
		params.put("LIKE_name", request.getParameter("LIKE_name") == null ? "" : request.getParameter("LIKE_name"));
		params.put("banben", request.getParameter("banben") == null ? "" : request.getParameter("banben"));
		ServletOutputStream os = null;
		try {
			os = response.getOutputStream(); // 获得输出流
			response.reset(); // 清空输出流
			String  filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";  
			int rownum = 1; // 添加的起始行
			


			ClassPathResource classPathResource = new ClassPathResource("/excel/report/report9.xlsx");
			XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
			response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
			// response.setContentType("application/msexcel"); //定义输出类型
			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
			response.setCharacterEncoding("utf-8");
			XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
			XSSFRow row;
			XSSFCell cell = null;
			XSSFCellStyle style = this.getxStyle(workbook);
			List<Map<String, Object>> list = zuoybKnowHowDetailsService.getKonwKdDetail(params);
			int endRow = rownum;
			int startRow = rownum;
			
			int idnum =5;
			int detailnum =11;
			int detailStartRow =rownum ;
			int detailEndRow = rownum;
			for (int i = 0; i < list.size(); i++) {
				row = sheet.createRow(rownum);
				int j = 0;
				myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("how_create_time")!=null?list.get(i).get("how_create_time").toString():"", row, cell, style); // 列1

				
				myCreateCellx(j++, list.get(i).get("detail_name")!=null?list.get(i).get("detail_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_id")!=null?list.get(i).get("detail_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("t11_module")!=null?list.get(i).get("t11_module").toString():"", row, cell, style); // 列1
				
				myCreateCellx(j++, list.get(i).get("two_module")!=null?list.get(i).get("two_module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("ydsl")!=null?list.get(i).get("ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_num")!=null?list.get(i).get("detail_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_create_time")!=null?list.get(i).get("detail_create_time").toString():"", row, cell, style); // 列1
				
				myCreateCellx(j++, list.get(i).get("k_id")!=null?list.get(i).get("k_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_name")!=null?list.get(i).get("k_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_ydsl")!=null?list.get(i).get("k_ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_img")!=null?list.get(i).get("k_img").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_level")!=null?list.get(i).get("k_level").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_label")!=null?list.get(i).get("k_label").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_num")!=null?list.get(i).get("k_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("k_create_time")!=null?list.get(i).get("k_create_time").toString():"", row, cell, style); // 列1
				if (i > 0) {
					
					
					if (list.get(i).get("detail_id").toString().equals(list.get(i - 1).get("detail_id").toString())) {
						detailEndRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						
					} else {
						if (detailStartRow != detailEndRow) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						
						detailStartRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						detailEndRow = rownum;// 合并结束行同合并开始行
					}
					
					
					if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
						endRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						
					} else {
						if (startRow != endRow) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
										));// 合并单元格
							}
						}
						startRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						endRow = rownum;// 合并结束行同合并开始行
					}
					
					
					
					
					
					
				}
				rownum++;
			}
			workbook.write(os);  
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(os != null){
				try {
					os.flush();
					os.close(); 
				} catch (IOException e) {
					e.printStackTrace();
				}  
			}
		}
	}



	@RequestMapping(value = "/exportHowExcel", method = RequestMethod.POST)
	@ResponseBody
	public void exportHowExcel(HttpServletRequest request, HttpServletResponse response,
							   @RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
							   String EQ_courseName,
							   String LIKE_name,
							   String EQ_grade,
							   Integer semester,
							   Integer banben

	) throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();

		StringBuffer fileName =new StringBuffer("单元");
		if(EQ_courseName != null){
			fileName.append(EQ_courseName);
		}
		if(EQ_grade != null){
			fileName.append(EQ_grade+"年级");
		}
		if(semester != null && !"".equals(semester)){
			fileName.append(semester==1?"上学期":"下学期");
		}

		params.put("EQ_libId", EQ_libId);
		params.put("LIKE_name", LIKE_name);
		params.put("banben", banben);
		ServletOutputStream os = null;
		try {
			os = response.getOutputStream(); // 获得输出流
			response.reset(); // 清空输出流

			String  filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
			int rownum = 1; // 添加的起始行



			ClassPathResource classPathResource = new ClassPathResource("/excel/report/report13.xlsx");
			XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
			response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
			// response.setContentType("application/msexcel"); //定义输出类型
			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
			response.setCharacterEncoding("utf-8");
			XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
			XSSFRow row;
			XSSFCell cell = null;
			XSSFCellStyle style = this.getxStyle(workbook);
			List<Map<String, Object>>  list=zuoybKnowHowDetailsSortService.getKonwVersion(EQ_libId, EQ_courseName, EQ_grade, banben, semester, LIKE_name);
			int endRow = rownum;
			int startRow = rownum;

			int idnum =6;
			for (int i = 0; i < list.size(); i++) {
				row = sheet.createRow(rownum);
				int j = 0;
				myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("module")!=null?list.get(i).get("module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("create_time")!=null?list.get(i).get("create_time").toString():"", row, cell, style); // 列1



				myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("alias")!=null?list.get(i).get("alias").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
				if (i > 0) {



					if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
						endRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

					} else {
						if (startRow != endRow) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}
						startRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						endRow = rownum;// 合并结束行同合并开始行
					}






				}
				rownum++;
			}
			workbook.write(os);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(os != null){
				try {
					os.flush();
					os.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
	@RequestMapping(value = "/exportHowDetailsExcel", method = RequestMethod.POST)
	@ResponseBody
	public void exportHowDetailsExcel(HttpServletRequest request, HttpServletResponse response,
									  @RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
									  String EQ_courseName,
									  String LIKE_name,
									  String EQ_grade,
									  Integer semester,
									  Integer banben

	) throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();

		StringBuffer fileName =new StringBuffer("知识点");
		if(EQ_courseName != null){
			fileName.append(EQ_courseName);
		}
		if(EQ_grade != null){
			fileName.append(EQ_grade+"年级");
		}
		if(semester != null && !"".equals(semester)){
			fileName.append(semester==1?"上学期":"下学期");
		}

		params.put("EQ_libId", EQ_libId);
		params.put("LIKE_name", LIKE_name);
		params.put("banben", banben);
		ServletOutputStream os = null;
		try {
			os = response.getOutputStream(); // 获得输出流
			response.reset(); // 清空输出流

			String  filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
			int rownum = 1; // 添加的起始行



			ClassPathResource classPathResource = new ClassPathResource("/excel/report/report14.xlsx");
			XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());

			response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
			// response.setContentType("application/msexcel"); //定义输出类型
			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
			response.setCharacterEncoding("utf-8");
			XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
			XSSFRow row;
			XSSFCell cell = null;
			XSSFCellStyle style = this.getxStyle(workbook);
			List<Map<String, Object>>  list=zuoybKnowHowDetailsSortService.getKonwDetailVersion(EQ_libId, EQ_courseName, EQ_grade, banben, semester, LIKE_name);
			int endRow = rownum;
			int startRow = rownum;

			int idnum =6;
			int detailnum =23;
			int detailStartRow =rownum ;
			int detailEndRow = rownum;
			for (int i = 0; i < list.size(); i++) {
				row = sheet.createRow(rownum);
				int j = 0;
				myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("module")!=null?list.get(i).get("module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("t_create_time")!=null?list.get(i).get("t_create_time").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("detail_name")!=null?list.get(i).get("detail_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_id")!=null?list.get(i).get("detail_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("t11_module")!=null?list.get(i).get("t11_module").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("jxmb")!=null?list.get(i).get("jxmb").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("zdbx")!=null?list.get(i).get("zdbx").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("ydsl")!=null?list.get(i).get("ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("img")!=null?list.get(i).get("img").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("two_module")!=null?list.get(i).get("two_module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("before_name")!=null?list.get(i).get("before_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("after_name")!=null?list.get(i).get("after_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("type")!=null?list.get(i).get("type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("is_hot")!=null?list.get(i).get("is_hot").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("memorize")!=null?list.get(i).get("memorize").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("understanding")!=null?list.get(i).get("understanding").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("apply")!=null?list.get(i).get("apply").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("duration")!=null?list.get(i).get("duration").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("attr_type")!=null?list.get(i).get("attr_type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_num")!=null?list.get(i).get("detail_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_create_time")!=null?list.get(i).get("detail_create_time").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("alias")!=null?list.get(i).get("alias").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("s_module")!=null?list.get(i).get("s_module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_two_module")!=null?list.get(i).get("s_two_module").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_jxmb")!=null?list.get(i).get("s_jxmb").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_zdbx")!=null?list.get(i).get("s_zdbx").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_ydsl")!=null?list.get(i).get("s_ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_memorize")!=null?list.get(i).get("s_memorize").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_understanding")!=null?list.get(i).get("s_understanding").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_apply")!=null?list.get(i).get("s_apply").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("s_attr_type")!=null?list.get(i).get("s_attr_type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
				if (i > 0) {

					if (list.get(i).get("detail_id")!=null&&list.get(i).get("detail_id").toString().equals(list.get(i - 1).get("detail_id").toString())) {
						detailEndRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

					} else {
						if (detailStartRow != detailEndRow) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

						detailStartRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						detailEndRow = rownum;// 合并结束行同合并开始行
					}


					if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
						endRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

					} else {
						if (startRow != endRow) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}
						startRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						endRow = rownum;// 合并结束行同合并开始行
					}






				}
				rownum++;
			}
			workbook.write(os);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(os != null){
				try {
					os.flush();
					os.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
	@RequestMapping(value = "/exportHowDetailsKdExcel", method = RequestMethod.POST)
	@ResponseBody
	public void exportHowDetailsKdExcel(HttpServletRequest request, HttpServletResponse response,
										@RequestParam(required = false, defaultValue = "SSJ") String EQ_libId,
										String EQ_courseName,
										String LIKE_name,
										String EQ_grade,
										Integer semester,
										Integer banben

	) throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();

		StringBuffer fileName =new StringBuffer("考点");
		if(EQ_courseName != null){
			fileName.append(EQ_courseName);
		}
		if(EQ_grade != null){
			fileName.append(EQ_grade+"年级");
		}
		if(semester != null && !"".equals(semester)){
			fileName.append(semester==1?"上学期":"下学期");
		}

		params.put("EQ_libId", EQ_libId);
		params.put("LIKE_name", LIKE_name);
		params.put("banben", banben);
		ServletOutputStream os = null;
		try {
			os = response.getOutputStream(); // 获得输出流
			response.reset(); // 清空输出流

			String  filesName = new String(fileName.toString().getBytes("gb2312"), "ISO8859-1") +".xlsx";
			int rownum = 1; // 添加的起始行

			ClassPathResource classPathResource = new ClassPathResource("/excel/report/report15.xlsx");
			XSSFWorkbook workbook = new XSSFWorkbook(classPathResource.getInputStream());
			response.setHeader("Content-disposition", "attachment; filename=" + filesName); // 设定输出文件头
			// response.setContentType("application/msexcel"); //定义输出类型
			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
			response.setCharacterEncoding("utf-8");
			XSSFSheet sheet = workbook.getSheetAt(0); // 读取第一个工作簿
			XSSFRow row;
			XSSFCell cell = null;
			XSSFCellStyle style = this.getxStyle(workbook);
			List<Map<String, Object>>  list=zuoybKnowHowDetailsSortService.getKonwDetailKdVersion(EQ_libId, EQ_courseName, EQ_grade, banben, semester, LIKE_name);
			int endRow = rownum;
			int startRow = rownum;

			int idnum =5;
			int detailStartRow =rownum ;
			int detailEndRow = rownum;
			int detailnum =12;
			int kdnum =19;
			int kdStartRow =rownum ;
			int kdEndRow = rownum;
			for (int i = 0; i < list.size(); i++) {
				row = sheet.createRow(rownum);
				int j = 0;
				myCreateCellx(j++, list.get(i).get("course_name")!=null?list.get(i).get("course_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("name")!=null?list.get(i).get("name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("id").toString(), row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("num")!=null?list.get(i).get("num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("t_create_time")!=null?list.get(i).get("t_create_time").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("detail_name")!=null?list.get(i).get("detail_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_id")!=null?list.get(i).get("detail_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("t11_module")!=null?list.get(i).get("t11_module").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("jxmb")!=null?list.get(i).get("jxmb").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("zdbx")!=null?list.get(i).get("zdbx").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("ydsl")!=null?list.get(i).get("ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_num")!=null?list.get(i).get("detail_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("detail_create_time")!=null?list.get(i).get("detail_create_time").toString():"", row, cell, style); // 列1

				myCreateCellx(j++, list.get(i).get("d_id")!=null?list.get(i).get("d_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_name")!=null?list.get(i).get("d_name").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_ydsl")!=null?list.get(i).get("d_ydsl").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_img")!=null?list.get(i).get("d_img").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_num")!=null?list.get(i).get("d_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_label")!=null?list.get(i).get("d_label").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_level")!=null?list.get(i).get("d_level").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("d_create_time")!=null?list.get(i).get("d_create_time").toString():"", row, cell, style); // 列1



				myCreateCellx(j++, list.get(i).get("s_id")!=null?list.get(i).get("s_id").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("alias")!=null?list.get(i).get("alias").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("semester")!=null?list.get(i).get("semester").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_num")!=null?list.get(i).get("s_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("grade_num")!=null?list.get(i).get("grade_num").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_type")!=null?list.get(i).get("s_type").toString():"", row, cell, style); // 列1
				myCreateCellx(j++, list.get(i).get("s_create_time")!=null?list.get(i).get("s_create_time").toString():"", row, cell, style); // 列1
				if (i > 0) {

					if (list.get(i).get("detail_id")!=null&&list.get(i).get("detail_id").toString().equals(list.get(i - 1).get("detail_id").toString())) {
						detailEndRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

					} else {
						if (detailStartRow != detailEndRow) {
							for (int a = idnum; a < detailnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(detailStartRow, // first
										detailEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

						detailStartRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						detailEndRow = rownum;// 合并结束行同合并开始行
					}
					if (list.get(i).get("d_id")!=null&&list.get(i).get("d_id").toString().equals(list.get(i - 1).get("d_id").toString())) {
						kdEndRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = detailnum; a < kdnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(kdStartRow, // first
										kdEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

					} else {
						if (kdStartRow != kdEndRow) {
							for (int a = detailnum; a < kdnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(kdStartRow, // first
										kdEndRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

						kdStartRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						kdEndRow = rownum;// 合并结束行同合并开始行
					}


					if (list.get(i).get("id").toString().equals(list.get(i - 1).get("id").toString())) {
						endRow++;// 则合并结束行号+1
						if (i == list.size() - 1) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}

					} else {
						if (startRow != endRow) {
							for (int a = 0; a < idnum; a++) {
								sheet.addMergedRegion(new CellRangeAddress(startRow, // first
										endRow, // last row (0-based)
										a, // first column (0-based)
										a // last column (0-based)
								));// 合并单元格
							}
						}
						startRow = rownum;// 为下次合并做准备，把合并开始行号赋值为下一行开始号
						endRow = rownum;// 合并结束行同合并开始行
					}






				}
				rownum++;
			}
			workbook.write(os);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(os != null){
				try {
					os.flush();
					os.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	private XSSFCellStyle getxStyle(XSSFWorkbook workbook) {
		// 设置字体;
		XSSFFont font = workbook.createFont();
		// 设置字体大小;
		font.setFontHeightInPoints((short) 10);
		// 设置字体名字;
		font.setFontName("Courier New");
		// font.setItalic(true);
		// font.setStrikeout(true);
		// 设置样式;
		XSSFCellStyle style = workbook.createCellStyle();
		// 设置底边框;
		style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
		// 设置底边框颜色;
		style.setBottomBorderColor(HSSFColor.BLACK.index);
		// 设置左边框;
		style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
		// 设置左边框颜色;
		style.setLeftBorderColor(HSSFColor.BLACK.index);
		// 设置右边框;
		style.setBorderRight(HSSFCellStyle.BORDER_THIN);
		// 设置右边框颜色;
		style.setRightBorderColor(HSSFColor.BLACK.index);
		// 设置顶边框;
		style.setBorderTop(HSSFCellStyle.BORDER_THIN);
		// 设置顶边框颜色;
		style.setTopBorderColor(HSSFColor.BLACK.index);
		// 在样式用应用设置的字体;
		style.setFont(font);
		// 设置自动换行;
		style.setWrapText(false);
		// 设置水平对齐的样式为居中对齐;
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		// 设置垂直对齐的样式为居中对齐;
		style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		return style;
	}

	private void myCreateCellx(int cellnum, String value, XSSFRow row, XSSFCell cell, XSSFCellStyle style) {
		cell = row.createCell((short) cellnum);
		cell.setCellValue(new XSSFRichTextString(value));
		cell.setCellStyle(style);
	}
}
