package com.ssj.sys.controller;

import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
import com.ssj.framework.basic.common.bean.SplitPage;
import com.ssj.framework.basic.utils.DateHelper;
import com.ssj.framework.core.common.controller.BaseController;
import com.ssj.service.sys.counter.service.CounterService;
import com.ssj.service.weixin.library.service.IBookBorrowService;
import com.ssj.service.weixin.library.service.ILibJoinService;
import com.ssj.service.weixin.library.service.ILibVipService;
import com.ssj.service.weixin.library.service.LibUserHistoryService;
import com.ssj.service.weixin.order.service.OrderService;
import com.ssj.service.weixin.problem.service.ExperienceService;
import com.ssj.service.weixin.problem.service.ValidVipService;
import com.ssj.service.weixin.sales.service.ILibQdSaleService;
import com.ssj.service.weixin.sales.service.LibOrderDetailsService;
import com.ssj.service.weixin.sales.service.LibVipCodeService;
import com.ssj.sys.util.thirdparty.excel.CustomizeToExcel;
import com.ssj.sys.util.thirdparty.excel.ExcelColumn;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("sys/report")
public class ReportController extends BaseController {
	
	@Autowired
	private LibUserHistoryService libUserHistoryService;
	@Autowired
	private LibOrderDetailsService libOrderDetailsService;
	@Autowired
	private ExperienceService experienceService;
	@Autowired
	private ILibVipService libVipService;
	@Autowired
	private ILibJoinService libJoinService;
	@Autowired
	private LibVipCodeService libVipCodeService;
	@Autowired
	private CounterService counterService;
	@Autowired
	 private ValidVipService validVipService;
	
	@Autowired
	private ILibQdSaleService qdSaleService;
	
	@Autowired
	private OrderService orderService;
	
	@Autowired
	private IBookBorrowService bookBorrowService;
      
    public HSSFCellStyle getStyle(HSSFWorkbook workbook) {  
        //设置字体;  
        HSSFFont font = workbook.createFont();  
        //设置字体大小;  
        font.setFontHeightInPoints((short) 5);  
        //设置字体名字;  
        font.setFontName("Courier New");  
        //font.setItalic(true);  
        //font.setStrikeout(true);  
        //设置样式;  
        HSSFCellStyle 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;  
     }  
     @RequestMapping(value = "/exportReport", method = RequestMethod.POST)
	 @ResponseBody
	 public void exportReport( HttpServletRequest request, HttpServletResponse response,String reportType) {  
    	 ServletOutputStream os = null;
       try {  
    	   os = response.getOutputStream(); //获得输出流  
           response.reset();   //清空输出流  
           
           String fileName = "";

           int rownum = 0; //添加的起始行  
    	   
           XSSFWorkbook workbook = null; 
           if("1".equals(reportType)){   //人员配置CD
        	   fileName = new String("人员配置".getBytes("gb2312"), "ISO8859-1") +".xlsx";  
           }else if("2".equals(reportType)){ //价格配置CD
        	   fileName = new String("价格配置".getBytes("gb2312"), "ISO8859-1") +".xlsx";  
           }else if("3".equals(reportType)){ //订单明细CD
        	   fileName = new String("订单明细".getBytes("gb2312"), "ISO8859-1") +".xlsx";  
           }else if("4".equals(reportType)){//渠道统计明细（管理员,CD）
        	   fileName = new String("各馆月度销售情况".getBytes("gb2312"), "ISO8859-1") +".xlsx";  

			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report4.xlsx");
        	   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 4; //添加的起始行  
           }else if("5".equals(reportType)){ //财务月报（管理员，CD）
        	   fileName = new String("财务月报".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report5.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 5; //添加的起始行  
           }else if("6".equals(reportType)){ //总部认证组绩效报表（管理员查询）
        	   fileName = new String("人员月度销售情况".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report6.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 4; //添加的起始行  
           }else if("7".equals(reportType)){ //总部认证组绩效报表（管理员查询）
        	   fileName = new String("财务月报共享模式A".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report8.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 5; //添加的起始行  
           }else if("8".equals(reportType)){ //总部认证组绩效报表（管理员查询）
        	   fileName = new String("财务月报共享模式B".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report8.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 5; //添加的起始行  
           }else if("9".equals(reportType)){ //一对一资金流水管理
        	   fileName = new String("一对一资金流水".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report12.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 2; //添加的起始行  
           }else if("10".equals(reportType)){ //一对一销售分成管理
        	   fileName = new String("一对一销售分成管理".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report10.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 3; //添加的起始行  
           }else if("11".equals(reportType)){ //老师业绩表
        	   fileName = new String("老师业绩表".getBytes("gb2312"), "ISO8859-1") +".xlsx";
			   ClassPathResource classPathResource = new ClassPathResource("/excel/report/report11.xlsx");
			   workbook = new XSSFWorkbook(classPathResource.getInputStream());
        	   rownum = 3; //添加的起始行  
           }
           
           response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//           response.setContentType("application/msexcel"); //定义输出类型  
           response.setContentType("application/vnd.ms-excel;charset=UTF-8");
           response.setCharacterEncoding("utf-8");
           
        		/**
       		 * 报表1  人员配置  销售人员姓名	销售人员岗位	合作性质	联系方式	性别
       		 */
        	
        	if("1".equals(reportType)){
        		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  //数据源
        		List<ExcelColumn> myColumns = new ArrayList<ExcelColumn>();
           		myColumns.add(new ExcelColumn("销售人员姓名", "filed1", 20));
           		myColumns.add(new ExcelColumn("销售人员岗位", "filed2", 20));
           		myColumns.add(new ExcelColumn("联系方式", "filed4", 20));
           		myColumns.add(new ExcelColumn("性别", "filed5", 20));
           		CustomizeToExcel.downFile(myColumns, list, os);
        	}else if("2".equals(reportType)){         		
        		/**
           		 * 报表2 价格配置  产品类别	 产品明细 	原价	 折扣价	折扣价时间周期
           		 */
        		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  //数据源
        		List<ExcelColumn> myColumns2 = new ArrayList<ExcelColumn>();
	       		myColumns2.add(new ExcelColumn("产品类别", "filed1", 20));
	       		myColumns2.add(new ExcelColumn("产品明细", "filed2", 20));
	       		myColumns2.add(new ExcelColumn("原价", "filed3", 20));
	       		myColumns2.add(new ExcelColumn("折扣价", "filed4", 20));
	       		myColumns2.add(new ExcelColumn("折扣价时间周期", "filed5", 20));
	       		CustomizeToExcel.downFile(myColumns2, list, os);
        	}else if("3".equals(reportType)){
            	/**
           		 * 报表3 选图书馆	家长姓名	宝宝姓名	联系方式	就读学校	年级	其他服务	支付时间	产品类别	产品明细	新签/续费	金额	销售人员姓名	如何知晓私塾家
           		 */
        		Map<String, Object> searchParams = new  HashMap<String, Object>();
        		searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
        		searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
        		if(!"admin".equals(loginName())){
        			searchParams.put("orgCode", orgCodeStr());
    			}
        		searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
        		searchParams.put("order_no", request.getParameter("order_no")==null?"":request.getParameter("order_no"));
        		List<Map<String, Object>> list = libOrderDetailsService.getOrderDetailByOrgCode(searchParams); //数据源
        		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
        		
           		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
           		myColumns3.add(new ExcelColumn("订单编号", "order_no", 20));
           		myColumns3.add(new ExcelColumn("家长姓名", "parent_name", 20));
           		myColumns3.add(new ExcelColumn("宝宝姓名", "child_name", 20));
           		myColumns3.add(new ExcelColumn("联系方式", "phone", 20));
           		myColumns3.add(new ExcelColumn("就读学校", "school", 20));
           		myColumns3.add(new ExcelColumn("就读年级", "grade", 20));
           		//myColumns3.add(new ExcelColumn("其他服务", "other_service", 20));
           		myColumns3.add(new ExcelColumn("支付时间", "create_time", 20));
           		myColumns3.add(new ExcelColumn("结束时间", "end_time", 20));
           		myColumns3.add(new ExcelColumn("产品类型", "species", 20));
           		myColumns3.add(new ExcelColumn("产品明细", "type", 20));
           		myColumns3.add(new ExcelColumn("新签/续费", "d_type", 20));
           		myColumns3.add(new ExcelColumn("金额", "price", 20));
           		myColumns3.add(new ExcelColumn("销售人员姓名", "name", 20));
           		myColumns3.add(new ExcelColumn("订单模式", "d_libtype", 20));
           		
	       		CustomizeToExcel.downFile(myColumns3, list, os);
           }else{
                   XSSFSheet sheet = workbook.getSheetAt(0);   //读取第一个工作簿  
                   XSSFRow row;  
                   XSSFCell cell = null;  
                   XSSFCellStyle style = this.getxStyle(workbook);  
                   
                   
                   
                   if("4".equals(reportType)){
                	   Map<String, Object> searchParams = new  HashMap<String, Object>();
                	   searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
               		   searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
               		if(!"admin".equals(loginName())){
            			searchParams.put("orgCode", orgCodeStr());
        			}
               		   searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
                	   List<Map<String, Object>> list  =  libOrderDetailsService.getOrderDetailQuDao(searchParams);
                	   int endRow =  rownum;
                	   int startRow =  rownum;
                	   for(int i=0;i<list.size();i++){
                		   row = sheet.createRow(rownum);  
                		   int j = 0;  
                  	   myCreateCellx(j++, list.get(i).get("league_city").toString(), row, cell, style);    //列1   
                  	   myCreateCellx(j++, list.get(i).get("league_name").toString(), row, cell, style);    //列1   
                  	   myCreateCellx(j++, list.get(i).get("months").toString(), row, cell, style);    //列1   
                  	   myCreateCellx(j++, list.get(i).get("n_type").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("c_type").toString(), row, cell, style);    //列1  
              		   
              		   myCreateCellx(j++, list.get(i).get("ty_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("ty_price").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("lx_xin_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("lx_xin_price").toString(), row, cell, style);    //列1   
              		   
              		   myCreateCellx(j++, list.get(i).get("zm_xin_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("zm_xin_price").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("hj_xin_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("hj_xin_price").toString(), row, cell, style);    //列1   
              		   
              		   
              		   myCreateCellx(j++, list.get(i).get("hy_nk_xin_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("hy_nk_xin_price").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("hy_nk_xu_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++, list.get(i).get("hy_nk_xu_price").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++,  list.get(i).get("hy_yk_xin_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++,  list.get(i).get("hy_yk_xin_price").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++,  list.get(i).get("hy_yk_xu_count").toString(), row, cell, style);    //列1   
              		   myCreateCellx(j++,  list.get(i).get("hy_yk_xu_price").toString(), row, cell, style);    //列1  
              		   
              		   myCreateCellx(j++, list.get(i).get("xin_huiyuan_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xin_huiyuan_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xu_huiyuan_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xu_huiyuan_price").toString(), row, cell, style);    //列1  
              		   //vip卡         j
              		   myCreateCellx(j++, list.get(i).get("vip_ty_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_ty_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_yk_xin_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_yk_xin_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_yk_xu_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_yk_xu_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_nk_xin_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_nk_xin_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_nk_xu_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("vip_nk_xu_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xin_vip_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xin_vip_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xu_vip_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("xu_vip_price").toString(), row, cell, style);    //列1  
              		   
              		   myCreateCellx(j++, list.get(i).get("c009_xin_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c009_xin_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c010_xin_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c010_xin_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c011_xin_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c011_xin_price").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c012_xin_count").toString(), row, cell, style);    //列1  
              		   myCreateCellx(j++, list.get(i).get("c012_xin_price").toString(), row, cell, style);    //列1  
              		   
              		 if(i >0){      
                          	   if(list.get(i).get("n_type").toString().equals(list.get(i-1).get("n_type").toString())){
                          		 endRow++;//则合并结束行号+1  
                          		 if(i == list.size()-1){
                          			sheet.addMergedRegion(new CellRangeAddress(  
                                            startRow, //first row (0-based)  
                                            endRow, //last row  (0-based)     
                                            3, //first column (0-based)  
                                            3  //last column  (0-based)  
                                            ));//合并单元格
                          		 }
                          		     
                          	   }else{
                          		   if(startRow != endRow){
                          			   sheet.addMergedRegion(new CellRangeAddress(  
                                                 startRow, //first row (0-based)  
                                                 endRow, //last row  (0-based)     
                                                 3, //first column (0-based)  
                                                 3  //last column  (0-based)  
                                                 ));//合并单元格
                          		   }
                          		   
                          		  startRow = rownum;//为下次合并做准备，把合并开始行号赋值为下一行开始号  
                                  endRow = rownum;//合并结束行同合并开始行  
                          	   }
                  	   }  
              		 rownum++; 
                	 }  
                	   
                	    
                   }else if("5".equals(reportType)){
                	   Map<String, Object> searchParams = new  HashMap<String, Object>();
                	   searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
               		  searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
               		if(!"admin".equals(loginName())){
            			searchParams.put("orgCode", orgCodeStr());
        			}
               	 searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
                	   List<Map<String, Object>> list  =  libOrderDetailsService.getOrderDetailMonthByOrgCode(searchParams);
                	   for (Map<String, Object> map : list) {
                		   row = sheet.createRow(rownum);  
                		   int i = -1;
                		   myCreateCellx(++i, map.get("league_city").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("league_name").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("months").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xin_huiyuan_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xin_huiyuan_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xu_huiyuan_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xu_huiyuan_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("lx_xin_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("lx_xin_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("zm_xin_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("zm_xin_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("hj_xin_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("hj_xin_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("xin_vip_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xin_vip_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xu_vip_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xu_vip_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("xin_tese_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xin_tese_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("xin_ysx_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("xin_ysx_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("total_price").toString(), row, cell, style);    //列1  
                		   
                		   //总部SD
                		   myCreateCellx(++i, map.get("sd_hy_yk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_hy_yk_xin_price").toString(), row, cell, style);    //列1   
                		   
                		   myCreateCellx(++i, map.get("sd_hy_yk_xu_count").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("sd_hy_yk_xu_price").toString(), row, cell, style);    //列1  
                		   // ----------------------
                		   myCreateCellx(++i, map.get("sd_hy_nk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_hy_nk_xin_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("sd_hy_nk_xu_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_hy_nk_xu_price").toString(), row, cell, style);    //列1  
                		   
          				 
          				//   myCreateCellx(++i, map.get("sd_lx_xin_count").toString(), row, cell, style);    //列1   
          				//   myCreateCellx(++i, map.get("sd_lx_xin_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_zm_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_zm_xin_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_hj_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_hj_xin_price").toString(), row, cell, style);    //列1   
                		   
                		   
                		   myCreateCellx(++i, map.get("sd_vip_yk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_vip_yk_xin_price").toString(), row, cell, style);    //列1   
                		   
                		   myCreateCellx(++i, map.get("sd_vip_yk_xu_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_vip_yk_xu_price").toString(), row, cell, style);    //列1  
                		   
                		   myCreateCellx(++i, map.get("sd_vip_nk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_vip_nk_xin_price").toString(), row, cell, style);    //列1   
                		   
                		   myCreateCellx(++i, map.get("sd_vip_nk_xu_count").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("sd_vip_nk_xu_price").toString(), row, cell, style);    //列1  
                		   
                		   myCreateCellx(++i, map.get("sd_c009_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_c009_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("c009_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("sd_c010_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_c010_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("c010_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_c011_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_c011_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("c011_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_c012_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("sd_c012_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("c012_price").toString(), row, cell, style);    //列1   
                		   
                		   myCreateCellx(++i, map.get("zhichu").toString(), row, cell, style);    //列1   支出统计
                		   
                		   myCreateCellx(++i, map.get("company_total_price").toString(), row, cell, style);    //总部管理分成  
                		   myCreateCellx(++i, map.get("zixun_price").toString(), row, cell, style);    //咨询服务费
                		   myCreateCellx(++i, map.get("jysxf_price").toString(), row, cell, style);    //交易手续费  
                		   myCreateCellx(++i, map.get("zhichuTotal").toString(), row, cell, style);    //全部支出
                		   myCreateCellx(++i, map.get("balance_amount").toString(), row, cell, style);    //结算余额
                		   rownum++; 
					   }
                   }else if("6".equals(reportType)){ //6
                	   Map<String, Object> searchParams = new  HashMap<String, Object>();
                	   searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
               		  searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
               		if(!"admin".equals(loginName())){
            			searchParams.put("orgCode", orgCodeStr());
        			}
               		 searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
                	   List<Map<String, Object>> list  =  libOrderDetailsService.getOrderDetailZongBuRenZheng(searchParams);
                	   for (Map<String, Object> map : list) {
                		   row = sheet.createRow(rownum);  
                		   int i = -1;
                		   myCreateCellx(++i, map.get("league_city").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("league_name").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("name")!=null?map.get("name").toString():"", row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("c_type").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("months").toString(), row, cell, style);    //列1   
                		   
                		   myCreateCellx(++i, map.get("ty_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("ty_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("lx_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("lx_xin_price").toString(), row, cell, style);    //列1 
                		   
                		   myCreateCellx(++i, map.get("zm_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("zm_xin_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("hj_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("hj_xin_price").toString(), row, cell, style);    //列1 
                		   
                  		   
                		   myCreateCellx(++i, map.get("hy_nk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("hy_nk_xin_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("hy_nk_xu_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i,  map.get("hy_nk_xu_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i,  map.get("hy_yk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i,  map.get("hy_yk_xin_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i,  map.get("hy_yk_xu_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i,  map.get("hy_yk_xu_price").toString(), row, cell, style);    //列1   
                		   
                		   //会员卡统计数据
                		   myCreateCellx(++i, map.get("xin_huiyuan_count").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("xin_huiyuan_price").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("xu_huiyuan_count").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("xu_huiyuan_price").toString(), row, cell, style);    //列1  
                		   
                		   myCreateCellx(++i, map.get("vip_ty_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_ty_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("vip_yk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_yk_xin_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_yk_xu_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_yk_xu_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("vip_nk_xin_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_nk_xin_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_nk_xu_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("vip_nk_xu_price").toString(), row, cell, style);    //列1 
                		   
                		   //会员卡统计数据
                		   myCreateCellx(++i, map.get("xin_vip_count").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("xin_vip_price").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("xu_vip_count").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("xu_vip_price").toString(), row, cell, style);    //列1  
                		   
                		   
                		   myCreateCellx(++i, map.get("c009_xin_count").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c009_xin_price").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c010_xin_count").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c010_xin_price").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c011_xin_count").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c011_xin_price").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c012_xin_count").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("c012_xin_price").toString(), row, cell, style);    //列1 
                  		   
                		   rownum++; 
					   }
                   }else if("7".equals(reportType)){
                	   Map<String, Object> searchParams = new  HashMap<String, Object>();
                	   searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
                	   searchParams.put("libtype", 2);
                	   searchParams.put("num", 60-1);
                	   searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
                		  searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
                	   List<Map<String, Object>> list  =  libOrderDetailsService.getOrderDetailMonthA(searchParams); 
                	   for (Map<String, Object> map : list) {
                		   row = sheet.createRow(rownum);  
                		   int i = -1;
                		   myCreateCellx(++i, map.get("league_city").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("qy_months_day").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("league_name").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("months").toString(), row, cell, style);    //列1   
                		 
                		   myCreateCellx(++i, map.get("huiyuan_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("huiyuan_price").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("bn_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("bn_price").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("zm_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("zm_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("total_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("total_price").toString(), row, cell, style);    //列1  
                		   
                		   myCreateCellx(++i, map.get("gltc_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("award_price").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("jysxf_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("pay_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("finally_price").toString(), row, cell, style);    //列1   
                		   rownum++; 
					   }
                   }else if("8".equals(reportType)){
                	   Map<String, Object> searchParams = new  HashMap<String, Object>();
                	   searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
                	   searchParams.put("libtype", 3);
                	   searchParams.put("num", 35-1);
                	   searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
                		  searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
                	   List<Map<String, Object>> list  =  libOrderDetailsService.getOrderDetailMonthA(searchParams); 
                	   for (Map<String, Object> map : list) {
                		   row = sheet.createRow(rownum);  
                		   int i = -1;
                		   myCreateCellx(++i, map.get("league_city").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("qy_months_day").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("league_name").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("months").toString(), row, cell, style);    //列1   
                		 
                		   myCreateCellx(++i, map.get("huiyuan_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("huiyuan_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("bn_count").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("bn_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("zm_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("zm_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("total_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("total_price").toString(), row, cell, style);    //列1  
                		   
                		   myCreateCellx(++i, map.get("gltc_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("award_price").toString(), row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("jysxf_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("pay_price").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("finally_price").toString(), row, cell, style);    //列1   
                		   rownum++; 
					   }
                	   
                   }else if("9".equals(reportType)){
                	 Map<String, Object> params = new HashMap<String, Object>();
              		 params.put("order_status", request.getParameter("order_status")==null?"":request.getParameter("order_status"));
              		 params.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
              		 params.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
              		 params.put("order_no", request.getParameter("order_no")==null?"":request.getParameter("order_no"));
              		 Integer pageNo=1;
              		 Integer pageSize=1000000;
              		 SplitPage sp = new SplitPage();
              	        sp.setAction(request.getRequestURI().toString());
              	        sp.setPageNo(1);
              	        sp.setPageSize(1000000);
              	        sp.setParams(params);
              	     Page<Map<String, Object>>  page= orderService.findForPageLessonServiceList(params, initPage(pageNo,pageSize));
              	     List<Map<String, Object>> list  = page.getContent();
                	   for (Map<String, Object> map : list) {
                		   row = sheet.createRow(rownum); 
                		   Integer order_status=(Integer)map.get("order_status");
                		   Integer sexInt=Integer.parseInt((map.get("sex")!=null ? map.get("sex").toString() : "0"));
                		   String orderStatus="";
                		   String sex="";
                		   switch (sexInt) {
	                		   case 1:
	                			   sex="男";
									break;
	                		   case 2:
	                			   sex="女";
									break;
	                			default:
	                				sex="未知";
									break;
                		   }
                		   switch (order_status) {
							case 0:
								orderStatus="未支付";
								break;
							case 1:
								orderStatus="已支付";
								break;
							case 2:
								orderStatus="已取消";
								break;
							case 3:
								orderStatus="已完成";
								break;
							case 4:
								orderStatus="tuikuan";
								break;
							default:
								break;
							}
                		   int i = -1;
                		   myCreateCellx(++i, map.get("league_name").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, map.get("order_no").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("create_time").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, orderStatus, row, cell, style);    //列1   
                		 
                		   myCreateCellx(++i, map.get("order_money").toString(), row, cell, style);    //列1 
                		   myCreateCellx(++i, "1".equals(map.get("is_listen_test").toString())?"有":"无", row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("course_count").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("start_time").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("end_time").toString(), row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("grade")!=null ? map.get("grade").toString():"", row, cell, style);    //列1  
                		   
                		   myCreateCellx(++i, map.get("course_name")!=null ? map.get("course_name").toString() : "", row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("parent_name")!=null ? map.get("parent_name").toString() : "", row, cell, style);    //列1  
                		   myCreateCellx(++i, map.get("phone")!=null ? map.get("phone").toString() :"", row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("child_name")!=null?  map.get("child_name").toString() :"", row, cell, style);    //列1   
                		   myCreateCellx(++i, sex, row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("family")!=null ? map.get("family").toString() :"", row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("master_name")!=null ? map.get("master_name").toString() :"", row, cell, style);    //列1   
                		   myCreateCellx(++i, map.get("master_telephone")!=null ? map.get("master_telephone").toString() : "", row, cell, style);    //列1   
                		   rownum++; 
					   }
                   }else if("10".equals(reportType)){
                	    Map<String, Object> params = new HashMap<String, Object>();
	               		params.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
	               		params.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
	               		params.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
	               		params.put("order_no", request.getParameter("order_no")==null?"":request.getParameter("order_no"));
	               	    Integer pageNo=1;
	        		    Integer pageSize=1000000;
	               		SplitPage sp = new SplitPage();
	               		sp.setAction(request.getRequestURI().toString());
	               		sp.setPageNo(pageNo);
	               		sp.setPageSize(pageSize);
	               		sp.setParams(params);
	               		Page<Map<String, Object>>  page= orderService.findForPageLessonServiceByCourseList(params, initPage(pageNo,pageSize));
	                	List<Map<String, Object>> list  = page.getContent();
	                  	for (Map<String, Object> map : list) {
                  		   row = sheet.createRow(rownum);  
                  		   int i = -1;
                  		   myCreateCellx(++i, map.get("order_no").toString(), row, cell, style);    //列1 
                  		   myCreateCellx(++i, map.get("child_name")!=null ? map.get("child_name").toString():"", row, cell, style);    //列1
                  		   myCreateCellx(++i, map.get("parent_name")!=null ? map.get("parent_name").toString():"", row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("phone")!=null ? map.get("phone").toString() :"", row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("league_name").toString(), row, cell, style);    //列1   
                  		 
                  		   myCreateCellx(++i, map.get("master_name")!=null ? map.get("master_name").toString() :"", row, cell, style);    //列1 
                  		   myCreateCellx(++i, map.get("master_telephone")!=null ? map.get("master_telephone").toString():"", row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("course_name")!=null? map.get("course_name").toString():"", row, cell, style);    //列1   
                  		   myCreateCellx(++i, (map.get("teacher_type")!=null ? map.get("teacher_type").toString(): "")+"/"+
                  				 (map.get("teacher_lever") !=null ? map.get("teacher_lever").toString() :""), row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("t_name")!=null ? map.get("t_name").toString() :"", row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("t_telephone")!=null ? map.get("t_telephone").toString() :"", row, cell, style);    //列1  
                  		   
                  		   myCreateCellx(++i, map.get("course_time").toString(), row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("start_time").toString(), row, cell, style);    //列1  
                  		   myCreateCellx(++i, map.get("end_time").toString(), row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("finish_time")!=null ? map.get("finish_time").toString() :"", row, cell, style);    //列1   
                  		   
                  		   myCreateCellx(++i, map.get("price").toString(), row, cell, style);    //列1  
                  		   
                  		   myCreateCellx(++i, map.get("t_price").toString(), row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("s_price").toString(), row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("l_price").toString(), row, cell, style);    //列1   
                  		   myCreateCellx(++i, map.get("sd_price").toString(), row, cell, style);    //列1   
                  		   rownum++; 
  					   }
                     }else if("11".equals(reportType)){
                 	    Map<String, Object> params = new HashMap<String, Object>();
 	               		params.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
 	               		params.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
 	               		params.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
 	               		params.put("order_no", request.getParameter("order_no")==null?"":request.getParameter("order_no"));
 	               	    Integer pageNo=1;
 	        		    Integer pageSize=1000000;
 	               		SplitPage sp = new SplitPage();
 	               		sp.setAction(request.getRequestURI().toString());
 	               		sp.setPageNo(pageNo);
 	               		sp.setPageSize(pageSize);
 	               		sp.setParams(params);
 	               		Page<Map<String, Object>>  page= orderService.findForPageLessonServiceByTeacherList(params, initPage(pageNo,pageSize));
 	                	List<Map<String, Object>> list  = page.getContent();
 	                  	for (Map<String, Object> map : list) {
 		                  	   Integer sexInt=Integer.parseInt((map.get("sex")!=null ? map.get("sex").toString() : "0"));
 	                		   String sex="";
 	                		   switch (sexInt) {
 		                		   case 1:
 		                			   sex="男";
 										break;
 		                		   case 2:
 		                			   sex="女";
 										break;
 		                			default:
 		                				sex="未知";
 										break;
 	                		   }
 	                  		   row = sheet.createRow(rownum);  
 	                  		   int i = -1;
 	                  		   myCreateCellx(++i, params.get("beginDate").toString(), row, cell, style);    //列1 
 	                  		   myCreateCellx(++i, params.get("endDate").toString(), row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("league_city")!=null ? map.get("league_city").toString() :"", row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("name")!=null ? map.get("name").toString():"", row, cell, style);    //列1   
 	                  		 
 	                  		   myCreateCellx(++i, map.get("telephone")!=null ? map.get("telephone").toString() :"", row, cell, style);    //列1 
 	                  		   myCreateCellx(++i, sex, row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("teacher_type")!=null? map.get("teacher_type").toString():"", row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("teacher_lever")!=null ? map.get("teacher_lever").toString(): "", row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("course_name")!=null ? map.get("course_name").toString() :"", row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("m_name")!=null ? map.get("m_name").toString() :"", row, cell, style);    //列1  
 	                  		   myCreateCellx(++i, map.get("m_telephone")!=null ? map.get("m_telephone").toString() :"", row, cell, style);    //列1  
 	                  		   myCreateCellx(++i, map.get("league_name")!=null ? map.get("league_name").toString() :"", row, cell, style);    //列1  
 	                  		   myCreateCellx(++i, map.get("new_count").toString(), row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("to_count").toString(), row, cell, style);    //列1  
 	                  		   myCreateCellx(++i, map.get("r_count").toString(), row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("tr_count").toString(), row, cell, style);    //列1  
 	                  		   
 	                  		   myCreateCellx(++i, map.get("c_count").toString(), row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("p_count")!=null ? map.get("p_count").toString() :"0.00", row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("nc_count").toString(), row, cell, style);    //列1   
 	                  		   myCreateCellx(++i, map.get("noc_count").toString(), row, cell, style);    //列1   
 	                  		   rownum++; 
 	                  	}
                      }
                   workbook.write(os);  
           } 
       }catch (IOException e) {  
          e.printStackTrace();  
       }catch (Exception e1){
    	   e1.printStackTrace();
       }finally{
    	   if(os != null){
	    		try {
					os.flush();
					os.close(); 
				} catch (IOException e) {
					e.printStackTrace();
				}  
    	   }
    	   
       }
           
           
   }
    
    public 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);  
    } 
    
    
    @RequestMapping(value = "/exportXlsx", method = RequestMethod.POST)
	 @ResponseBody
	 public void exportXlsx( HttpServletRequest request, HttpServletResponse response) {  
   	 ServletOutputStream os = null;
      try {  
   	   os = response.getOutputStream(); //获得输出流  
          response.reset();   //清空输出流  
           String fileName = new String("图书馆会员服务".getBytes("gb2312"), "ISO8859-1") +".xlsx";  
          response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
          response.setContentType("application/vnd.ms-excel;charset=UTF-8");
          response.setCharacterEncoding("utf-8");
          
       		/**
      		 * 报表1  人员配置  销售人员姓名	销售人员岗位	合作性质	联系方式	性别
      		 */
       	
           	/**
          		 * 报表3 选图书馆	家长姓名	宝宝姓名	联系方式	就读学校	年级	其他服务	支付时间	产品类别	产品明细	新签/续费	金额	销售人员姓名	如何知晓私塾家
          		 */
       		Map<String, Object> searchParams = new  HashMap<String, Object>();
       		searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
       		searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
       		searchParams.put("child_name",request.getParameter("child_name") == null ? "" : request.getParameter("child_name"));
       		searchParams.put("level",request.getParameter("level") == null ? "" : request.getParameter("level"));
       		searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
       		List<Map<String, Object>> list = libVipService.getLibVipList(searchParams); //数据源
       		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
          		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
          		myColumns3.add(new ExcelColumn("持有人", "child_name", 20));
          		myColumns3.add(new ExcelColumn("激活时间", "start_time", 20));
          		myColumns3.add(new ExcelColumn("购卡服务", "type", 20));
          		myColumns3.add(new ExcelColumn("会员类型", "level", 20));
          		myColumns3.add(new ExcelColumn("会员卡编号", "flow_id", 20));
	       		CustomizeToExcel.downFile(myColumns3, list, os);
      }catch (IOException e) {  
         e.printStackTrace();  
      }catch (Exception e1){
   	   e1.printStackTrace();
      }finally{
   	   if(os != null){
	    		try {
					os.flush();
					os.close(); 
				} catch (IOException e) {
					e.printStackTrace();
				}  
   	   }
   	   
      }
          
          
  }
    /**
     * 
    * @param request
    * @param response
    * 创建人：ZhangCaibao 
    * 2017年6月21日 下午3:28:48 
    * @void
     */
    @RequestMapping(value = "/exportLibVipCode", method = RequestMethod.POST)
    @ResponseBody
    public void exportLibVipCode( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try {  
    		String EQ_libId=(String) request.getParameter("EQ_libId");
    		TbLibJoin tbLibJoin=	libJoinService.getById(EQ_libId);
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(tbLibJoin.getLeagueName().getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		
    		/**
    		 * 报表1  人员配置  销售人员姓名	销售人员岗位	合作性质	联系方式	性别
    		 */
    		
    		/**
    		 * 报表3 选图书馆	家长姓名	宝宝姓名	联系方式	就读学校	年级	其他服务	支付时间	产品类别	产品明细	新签/续费	金额	销售人员姓名	如何知晓私塾家
    		 */
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
    		searchParams.put("EQ_libId", EQ_libId);
    		searchParams.put("EQ_type",request.getParameter("EQ_type") == null ? "" : request.getParameter("EQ_type"));
    		List<Map<String, Object>> list = libVipCodeService.getLibVipCodeList(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("激活码", "vip_code", 20));
    		myColumns3.add(new ExcelColumn("折扣", "discount", 20));
    		myColumns3.add(new ExcelColumn("类型", "type", 20));
    		myColumns3.add(new ExcelColumn("使用人", "wx_name", 20));
    		myColumns3.add(new ExcelColumn("添加时间", "create_time", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }
    @RequestMapping(value = "/exportLibQG", method = RequestMethod.POST)
    @ResponseBody
    public void exportLibQG( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="图书馆到馆离馆详细表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
    		searchParams.put("child_name", request.getParameter("child_name")== null ? "":request.getParameter("child_name"));
    		searchParams.put("ryke_time", request.getParameter("ryke_time")== null ? "":request.getParameter("ryke_time"));
    		searchParams.put("libId", request.getParameter("libId")== null ? "":request.getParameter("libId"));
    		if(!"admin".equals(loginName())){
    			searchParams.put("orgCode", orgCodeStr());
			}
    		List<Map<String, Object>> list = libUserHistoryService.getLibQGList(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("姓名", "child_name", 20));
    		myColumns3.add(new ExcelColumn("签到时间", "sb", 20));
    		myColumns3.add(new ExcelColumn("签离时间", "sx", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }
    @RequestMapping(value = "/exportLibYD", method = RequestMethod.POST)
    @ResponseBody
    public void exportLibYD( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="图书馆月度到馆离馆统计表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
    		searchParams.put("child_name", request.getParameter("child_name")== null ? "":request.getParameter("child_name"));
    		 String date =  DateHelper.format(new Date(), "yyyy-MM");
			 String  monthDate = request.getParameter("monthDate")== null ? date:request.getParameter("monthDate");
			 searchParams.put("monthDate", monthDate);
			 searchParams.put("libId", request.getParameter("libId")== null ? "":request.getParameter("libId"));
			 if(!"admin".equals(loginName())){
     			searchParams.put("orgCode", orgCodeStr());
 			}
    		List<Map<String, Object>> list = libUserHistoryService.getLibYDList(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("姓名", "child_name", 20));
    		myColumns3.add(new ExcelColumn("签到次数", "frequency", 20));
    		myColumns3.add(new ExcelColumn("签到率", "qdl", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }
    @RequestMapping(value = "/exportLibEX", method = RequestMethod.POST)
    @ResponseBody
    public void exportLibEX( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String("0元活动".getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
    		searchParams.put("name", request.getParameter("name")== null ? "":request.getParameter("name"));
    		searchParams.put("grade", request.getParameter("grade")==null?"":request.getParameter("grade"));
    		searchParams.put("type", request.getParameter("type")==null?"":request.getParameter("type"));
    		searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
    		searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
    		List<Map<String, Object>> list = experienceService.getExpList(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("学生姓名", "name", 20));
    		myColumns3.add(new ExcelColumn("就读年级", "grade", 20));
    		myColumns3.add(new ExcelColumn("联系电话", "phone", 20));
    		myColumns3.add(new ExcelColumn("类别", "stat", 20));
    		myColumns3.add(new ExcelColumn("科目", "course", 20));
    		myColumns3.add(new ExcelColumn("提交时间", "sj", 20));
    		myColumns3.add(new ExcelColumn("图书馆", "library", 20));
    		myColumns3.add(new ExcelColumn("信息来源", "ly", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    }
    
    /**
     * wuwen
     * //营业额增长
   	 *	//会员增长
   	 *	2017年12月7日13:59:39
     * @param request
     * @param response
     */

    @RequestMapping(value = "/exportUserAndOrder", method = RequestMethod.POST)
    @ResponseBody
    public void exportUserAndOrder( HttpServletRequest request, HttpServletResponse response,String type,String startDate, String endDate,String selectLibId) {  
    	ServletOutputStream os = null;
    	try { 
    		String name="会员增长"+startDate+"~"+endDate;
    		if("ORDERDAY".equals(type)){
    			name="营业额增长"+startDate+"~"+endDate;
    		}
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(name.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
    		
    		SimpleDateFormat formatter= new SimpleDateFormat ("yyyy-MM-dd"); 
    	    Date startTime = formatter.parse(startDate);
    	    Date endTime = formatter.parse(endDate);
    	    String libId="";
    	    if(StringUtils.isNotEmpty(selectLibId)){
    	    	libId=selectLibId;
    	    }else{
	    	    List<TbLibJoin> lists= libJoinService.getLibJoinByCode(orgcodeList());
	    	    if(list!=null && list.size()>0){
	    	    	for (TbLibJoin tbLibJoin : lists) {
	    	    		libId+=tbLibJoin.getId()+";";
					}
	    	    	libId=libId.substring(0, libId.length()-1);
	    	    }
    	    }
    	    list=counterService.selectByCounter(libId, type, startTime, endTime);
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("日期", "count_time", 20));
    		myColumns3.add(new ExcelColumn("数据", "count", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    	}
    }
    
    @RequestMapping(value = "/exportValidVip", method = RequestMethod.POST)
    @ResponseBody
    public void exportValidVip( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="每月家庭馆有效会员表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
    		searchParams.put("months", request.getParameter("months")== null ? "":request.getParameter("months"));
			searchParams.put("libId", request.getParameter("libId")== null ? "":request.getParameter("libId"));
			searchParams.put("type", request.getParameter("type")== null ? "":request.getParameter("type"));
		    if(!"admin".equals(loginName())){
    			searchParams.put("orgCode", orgCodeStr());
			}
    		List<Map<String, Object>> list = validVipService.getValidVipList(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("会员总数", "vip_total", 20));
    		myColumns3.add(new ExcelColumn("家庭数", "family", 20));
    		myColumns3.add(new ExcelColumn("借阅卡年卡", "year_card", 20));
    		myColumns3.add(new ExcelColumn("借阅卡半年卡", "half_card", 20));
    		myColumns3.add(new ExcelColumn("借阅卡月卡", "month_card", 20));
    		myColumns3.add(new ExcelColumn("周末卡", "weekend_card", 20));
    		myColumns3.add(new ExcelColumn("作业卡月卡", "task_card", 20));
    		myColumns3.add(new ExcelColumn("作业卡年卡", "taskyear_card", 20));
    		myColumns3.add(new ExcelColumn("寒假卡", "holiday", 20));
    		myColumns3.add(new ExcelColumn("特色课", "features", 20));
    		myColumns3.add(new ExcelColumn("类别", "type", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }
    @RequestMapping(value = "/exportQdSales", method = RequestMethod.POST)
    @ResponseBody
    public void exportQdSales( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="销售人员打款记录表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
		    searchParams.put("startTime", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
		    searchParams.put("endTime", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
		    searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
		    searchParams.put("stat", request.getParameter("stat")==null?"":request.getParameter("stat"));
		    if(!"admin".equals(loginName())){
    			searchParams.put("orgCode", orgCodeStr());
			}
    		List<Map<String, Object>> list = qdSaleService.getForList(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("销售人员", "name", 20));
    		myColumns3.add(new ExcelColumn("产品类型", "details", 20));
    		myColumns3.add(new ExcelColumn("企业付款金额", "sales_fee", 20));
    		myColumns3.add(new ExcelColumn("企业付款状态", "stat", 20));
    		myColumns3.add(new ExcelColumn("孩子姓名", "child_name", 20));
    		myColumns3.add(new ExcelColumn("订单号", "order_no", 20));
    		myColumns3.add(new ExcelColumn("企业付款时间", "sj", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }
    
    
    @RequestMapping(value = "/exportActivity", method = RequestMethod.POST)
    @ResponseBody
    public void exportActivity( HttpServletRequest request, HttpServletResponse response,String selectLibId) {  
    	ServletOutputStream os = null;
    	try { 
    		String name="到馆活跃度比例";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(name.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
    		
    	    String libId="";
    	    if(StringUtils.isNotEmpty(selectLibId)){
    	    	libId=selectLibId;
    	    }else{
	    	    List<TbLibJoin> lists= libJoinService.getLibJoinByCode(orgcodeList());
	    	    if(list!=null && list.size()>0){
	    	    	for (TbLibJoin tbLibJoin : lists) {
	    	    		libId+=tbLibJoin.getId()+";";
					}
	    	    	libId=libId.substring(0, libId.length()-1);
	    	    }
    	    }
    	    list.addAll(counterService.exportActive(libId));
    	    list.addAll(counterService.exportImminent(libId));
    	    list.addAll(counterService.exportSilent(libId));
    	    
    	    
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("家长姓名", "parent_name", 20));
    		myColumns3.add(new ExcelColumn("孩子姓名", "child_name", 20));
    		myColumns3.add(new ExcelColumn("联系电话", "phone", 20));
    		myColumns3.add(new ExcelColumn("所在学校", "school", 20));
    		myColumns3.add(new ExcelColumn("所在年级", "grade", 20));
    		myColumns3.add(new ExcelColumn("服务跟进人", "wx_name", 20));
    		myColumns3.add(new ExcelColumn("活跃状态", "e_type", 20));
    		myColumns3.add(new ExcelColumn("服务类型", "speciesname", 20));
    		myColumns3.add(new ExcelColumn("购卡卡类", "typename", 20));
    		myColumns3.add(new ExcelColumn("购卡时间", "create_time", 20));
    		myColumns3.add(new ExcelColumn("服务结束", "end_time", 20));

    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    	}
    }
    
    
    @RequestMapping(value = "/exportOrder", method = RequestMethod.POST)
    @ResponseBody
    public void exportOrder( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="资金流水表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
		    searchParams.put("order_status", request.getParameter("order_status")==null?"":request.getParameter("order_status"));
		    searchParams.put("order_type", request.getParameter("order_type")==null?"":request.getParameter("order_type"));
		    searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
		    searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
		    searchParams.put("order_no", request.getParameter("order_no")==null?"":request.getParameter("order_no"));
		    if(!"admin".equals(loginName())){
    			searchParams.put("orgCode", orgCodeStr());
			}
    		List<Map<String, Object>> list = orderService.getOrder(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("下单人", "wx_name", 20));
    		myColumns3.add(new ExcelColumn("订单编号", "order_no", 20));
    		myColumns3.add(new ExcelColumn("订单类型", "order_type2", 20));
    		myColumns3.add(new ExcelColumn("订单状态", "order_status2", 20));
    		myColumns3.add(new ExcelColumn("订单金额", "order_money", 20));
    		myColumns3.add(new ExcelColumn("下单时间", "create_time2", 20));
    		myColumns3.add(new ExcelColumn("支付成功时间", "pay_time2", 20));
    		myColumns3.add(new ExcelColumn("退款时间", "refund_time", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }
    
    @RequestMapping(value = "/exportValidVip2", method = RequestMethod.POST)
    @ResponseBody
    public void exportValidVip2( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="共享馆有效会员表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
			searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
			searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
			searchParams.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
		    if(!"admin".equals(loginName())){
    			searchParams.put("orgCode", orgCodeStr());
			}
    		List<Map<String, Object>> list = validVipService.getValidVipList2(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("会员总数", "vip_total", 20));
    		myColumns3.add(new ExcelColumn("家庭数", "family", 20));
    		myColumns3.add(new ExcelColumn("借阅卡年卡", "year_card", 20));
    		myColumns3.add(new ExcelColumn("周末卡", "weekend_card", 20));
    		myColumns3.add(new ExcelColumn("作业卡年卡", "taskyear_card", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    	
    	
    }   
    

    @RequestMapping(value = "/exportWishOrder", method = RequestMethod.POST)
    @ResponseBody
    public void exportWishOrder( HttpServletRequest request, HttpServletResponse response) {  
    	ServletOutputStream os = null;
    	try { 
    		String libName="共享馆心愿达成表";
    		os = response.getOutputStream(); //获得输出流  
    		response.reset();   //清空输出流  
    		String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";  
    		response.setHeader("Content-disposition", "attachment; filename="+ fileName); //设定输出文件头  
//          response.setContentType("application/msexcel"); //定义输出类型  
    		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    		response.setCharacterEncoding("utf-8");
    		Map<String, Object> searchParams = new  HashMap<String, Object>();
//			searchParams.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
//			searchParams.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
    		searchParams.put("lib_name",request.getParameter("lib_name") == null ? "" : request.getParameter("lib_name"));
//		    if(!"admin".equals(loginName())){
//    			searchParams.put("orgCode", orgCodeStr());
//			}
    		List<Map<String, Object>> list = bookBorrowService.getExportData(searchParams); //数据源
    		List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
    		myColumns3.add(new ExcelColumn("图书馆", "league_name", 20));
    		myColumns3.add(new ExcelColumn("心愿发起人", "child_name", 20));
    		myColumns3.add(new ExcelColumn("心愿助力数", "count1", 20));
    		myColumns3.add(new ExcelColumn("心愿书籍名称", "title", 20));
    		myColumns3.add(new ExcelColumn("心愿书籍isbn", "isbn13", 20));
    		CustomizeToExcel.downFile(myColumns3, list, os);
    	}catch (IOException e) {  
    		e.printStackTrace();  
    	}catch (Exception e1){
    		e1.printStackTrace();
    	}finally{
    		if(os != null){
    			try {
    				os.flush();
    				os.close(); 
    			} catch (IOException e) {
    				e.printStackTrace();
    			}  
    		}
    		
    	}
    }  
}
