/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.manager.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
import io.swagger.annotations.*;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import lombok.SneakyThrows;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springblade.common.utils.SnowFlakeUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;

import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.manager.entity.ExctabCell;
import org.springblade.manager.entity.WbsTreePrivate;
import org.springblade.manager.service.IExctabCellService;
import org.springblade.manager.service.IWbsTreePrivateService;
import org.springblade.manager.service.IWbsTreeService;
import org.springblade.manager.vo.*;
import org.springblade.manager.wrapper.ExcelTabWrapper;
import org.springblade.resource.feign.IOSSClient;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.manager.entity.ExcelTab;
import org.springblade.manager.service.IExcelTabService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 清表基础数据表 控制器
 *
 * @author BladeX
 * @since 2022-05-18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/exceltab")
@Api(value = "清表基础数据表", tags = "清表基础数据表接口")
public class ExcelTabController extends BladeController {

	// excel 基本信息表
	private final IExcelTabService excelTabService;
	// wes 基本信息表
	private final IWbsTreeService wbsTreeService;
	// excel 解析结构
	private final IExctabCellService exctabCellService;

	private final IOSSClient iossClient;

	// 私有项目wbs
	private final IWbsTreePrivateService wbsTreePrivateService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入excelTab")
	public R<ExcelTabVO> detail(ExcelTab excelTab) {
		ExcelTab detail = excelTabService.getOne(Condition.getQueryWrapper(excelTab));
		return R.data(ExcelTabWrapper.build().entityVO(detail));
	}

	/**
	 * 分页 清表基础数据表
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入excelTab")
	public R<IPage<ExcelTabVO>> list(ExcelTab excelTab, Query query) {
		IPage<ExcelTab> pages = excelTabService.page(Condition.getPage(query), Condition.getQueryWrapper(excelTab));
		return R.data(ExcelTabWrapper.build().pageVO(pages));
	}


	/**
	 * 自定义分页 清表基础数据表
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入excelTab")
	public R<IPage<ExcelTabVO>> page(ExcelTabVO excelTab, Query query) {
		IPage<ExcelTabVO> pages = excelTabService.selectExcelTabPage(Condition.getPage(query), excelTab);
		return R.data(pages);
	}

	/**
	 * 新增 清表基础数据表
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入excelTab")
	public R save(@Valid @RequestBody ExcelTab excelTab) {
		if(Func.isEmpty(excelTab.getParentId())) {
			excelTab.setTenantId(AuthUtil.getTenantId());
			excelTab.setParentId(BladeConstant.TOP_PARENT_ID);
			excelTab.setIsDeleted(BladeConstant.DB_NOT_DELETED);
			excelTabService.save(excelTab);
			excelTab.setAlias(excelTab.getId()+"");
		}

		if (excelTab.getParentId() > 0) {
			ExcelTab parent = excelTabService.getById(excelTab.getParentId());
			if (Func.toLong(parent.getParentId()) == Func.toLong(excelTab.getId())) {
				throw new ServiceException("父节点不可选择自身!");
			}
			excelTab.setTenantId(parent.getTenantId());
			String ancestors = parent.getAlias() + StringPool.COMMA + excelTab.getParentId();
			excelTab.setAlias(ancestors);
			excelTab.setIsDeleted(BladeConstant.DB_NOT_DELETED);
		}
		return R.status(excelTabService.saveOrUpdate(excelTab));
	}

	/**
	 * 修改 清表基础数据表
	 */
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入excelTab")
	public R update(@Valid @RequestBody ExcelTab excelTab) {
		return R.status(excelTabService.updateById(excelTab));
	}

	/**
	 * 新增或修改 清表基础数据表
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入excelTab")
	public R submit(@Valid @RequestBody ExcelTab excelTab) {
		if(Func.isEmpty(excelTab.getParentId())) {
			excelTab.setTenantId(AuthUtil.getTenantId());
			excelTab.setParentId(BladeConstant.TOP_PARENT_ID);
			excelTab.setIsDeleted(BladeConstant.DB_NOT_DELETED);
			excelTab.setFileType(1); // 祖节点
			excelTabService.save(excelTab);
			excelTab.setAlias(excelTab.getId()+"");
		}

		if (excelTab.getParentId() > 0) {
			ExcelTab parent = excelTabService.getById(excelTab.getParentId());
			if (Func.toLong(parent.getParentId()) == Func.toLong(excelTab.getId())) {
				throw new ServiceException("父节点不可选择自身!");
			}
			excelTab.setTenantId(parent.getTenantId());
			String ancestors = parent.getAlias() + StringPool.COMMA + excelTab.getParentId();
			excelTab.setAlias(ancestors);
			excelTab.setIsDeleted(BladeConstant.DB_NOT_DELETED);
		}
		return R.status(excelTabService.saveOrUpdate(excelTab));
	}

	
	/**
	 * 删除 清表基础数据表
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 7)
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(excelTabService.deleteLogic(Func.toLongList(ids)));
	}


	/**
	 * 清表模版树
	 */
	@GetMapping("/tab-lazytree")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "清表清表树形结构", notes = "清表清表树形结构")
	public R<List<ExceTabTreVO>> tabLazyTree(Long parentId,Long modeId, BladeUser bladeUser) {
		List<ExceTabTreVO> tree = excelTabService.tabLazyTree( bladeUser.getTenantId(), modeId,parentId);
		return R.data(tree);
	}

	/**
	 * 上传文件
	 *
	 * @param file 文件
	 * @return ObjectStat
	 */
	@SneakyThrows
	@PostMapping("/put-file-attach")
	@ApiOperationSupport(order = 9)
	@ApiOperation(value = "清表上传", notes = "清表上传")
	@ApiImplicitParams(value = {
			@ApiImplicitParam(name = "file", value = "文件源", required = true),
			@ApiImplicitParam(name = "nodeId", value = "节点id", required = true)
	})
	public R putFileAttach(@RequestParam("file") MultipartFile file, Long nodeId) {

		ExcelTab detail = excelTabService.getById(nodeId);
		// 删除excel文件
		R<BladeFile> bladeFile = iossClient.addFileInfo(file);
		BladeFile bladeFile1 = bladeFile.getData();
		String filecode = SnowFlakeUtil.getId()+"";
		String thmlUrl = "/Users/hongchuangyanfa/Desktop/"+filecode+".html";
		// 解析excel
		Workbook wb = new Workbook();
		wb.loadFromMHtml(file.getInputStream());
		//获取工作表
		Worksheet sheet = wb.getWorksheets().get(0);
		sheet.saveToHtml(thmlUrl);
		detail.setExtension(bladeFile1.getOriginalName());
		detail.setFileUrl(bladeFile1.getLink());
		detail.setFileType(3); // 表示为清表信息  1 表示祖节点  2 表示为节点信息 3 表示清表
		detail.setHtmlUrl(thmlUrl);
		excelTabService.saveOrUpdate(detail);
/*
		//解析数据
		Thread.sleep(200);
		String htmlString =  readfile(thmlUrl);

		String htmlString2=  getBody(htmlString);

		Document doc = Jsoup.parse(htmlString2);

		Elements trs = doc.select("tr");
		List<ExctabCell> cellList = new ArrayList<>();

		for(int i = 0 ;i < trs.size() ;i++){
			Element tr = trs.get(i);
			Elements tds = tr.select("td");
			for( int j = 0 ; j < tds.size();j++ ){
				ExctabCell cell = new ExctabCell();
				Element data = tds.get(j);
				int colspan = Integer.parseInt(data.attr("COLSPAN").equals("")?"0":data.attr("COLSPAN"));
				int rowspan  = Integer.parseInt(data.attr("ROWSPAN").equals("")?"0":data.attr("ROWSPAN"));
				String textInfo = data.text();
				cell.setExctabId(nodeId);
				cell.setTrIndex(i);
				cell.setTdIndex(j);
				cell.setColIndex(colspan);
				cell.setRowIndex(rowspan);
				cell.setTextInfo(textInfo);
				cellList.add(cell);
				System.out.print("COLSPAN：" +colspan+" ROWSPAN:"+rowspan+" "+textInfo);
			}
			System.out.println();
		}

		// 保存结构
		exctabCellService.saveOrUpdateBatch(cellList);*/
		return R.success("上传成功");
	}



	/**
	 * 清表编辑 wbs 下拉框选择
	 */
	@GetMapping("/getWbsTypeList")
	@ApiOperationSupport(order = 10)
	@ApiOperation(value = "清表编辑 wbs 下拉框选择", notes = "传入excelTab")
	public R getWbsTypeList() {
		List<ExcelTabWbsTypeVO> wbsTypeList= excelTabService.getWbsTypeList();
		return R.data(wbsTypeList);
	}

	/**
	 * 清表编辑 - 下拉框 树节点
	 */
	@GetMapping("/lazy-tree")
	@ApiOperationSupport(order = 11)
	@ApiOperation(value = "懒加载节点树形结构", notes = "传入wbsId，parentId，请求头token")
	@ApiImplicitParams(value = {
			@ApiImplicitParam(name = "wbsId", value = "wbsId", required = true),
			@ApiImplicitParam(name = "parentId", value = "父级id", required = true),
			@ApiImplicitParam(name = "wbsType", value = "type", required = true)
	})
	public R<List<WbsTreeVO>> getLazyTreeById(String wbsId, Long parentId, BladeUser bladeUser, Integer wbsType) {
		if(wbsType==1){
			List<WbsTreeVO> tree = excelTabService.lazyTree(wbsId, Func.toStrWithEmpty(null, bladeUser.getTenantId()), parentId);
			if (tree != null && tree.size() > 0) {
				return R.data(tree);
			}
		}

		return R.fail(200, "未查询到信息");
	}

	/**
	 * 查询当前节点下所有表单（根据节点ID查询当前表单）
	 */
	@GetMapping("/selectByNodeTable")
	@ApiOperationSupport(order = 12)
	@ApiOperation(value = "查询当前节点下所有表单", notes = "传入父节点id")
	public R<List<WbsNodeTableVO>> selectByNodeTable(@ApiParam(value = "树节点Id", required = true) @RequestParam String id,
										 @ApiParam(value = "wbsType", required = true) @RequestParam Integer wbsType) {
		if(wbsType==1){
			List<WbsNodeTableVO> rs = wbsTreeService.selectByNodeTable(id);
			if (!("").equals(rs) && rs.size() > 0) {
				return R.data(rs);
			}
		}
		return R.fail(200, "未查询到数据");
	}


	/**
	 * 清表编辑 - 下拉框 树节点
	 */
	@PostMapping("/sava-dataInfo")
	@ApiOperationSupport(order = 13)
	@ApiOperation(value = "编辑-保存", notes = "编辑-保存")
	public R<List<WbsTreeVO>> savaDataInfo(@Valid @RequestBody WbsExclTabParmVO wbsExclTabParmVO, BladeUser bladeUser) {
		// 保存节点信息
		ExcelTab excelTab = new ExcelTab();
		if(wbsExclTabParmVO.getId()!=null){// 修改
			excelTab = excelTabService.getById(wbsExclTabParmVO.getId());
			excelTab.setName(wbsExclTabParmVO.getNodeName());
			excelTab.setTabType(wbsExclTabParmVO.getTabType());
		}else{ // 新增
			ExcelTab parent = excelTabService.getById(wbsExclTabParmVO.getParentId());
			excelTab.setParentId(wbsExclTabParmVO.getParentId());
			excelTab.setTabType(wbsExclTabParmVO.getTabType());
			excelTab.setName(wbsExclTabParmVO.getNodeName());
			excelTab.setIsDeleted(BladeConstant.DB_NOT_DELETED);
			excelTab.setFileType(2);
			String ancestors = parent.getAlias() + StringPool.COMMA + excelTab.getParentId();
			excelTab.setAlias(ancestors);
		}
		excelTabService.saveOrUpdate(excelTab);
		return R.success("添加成功!");
	}

	public static String readfile(String filePath){
		File file = new File(filePath);
		InputStream input = null;
		try {
			input = new FileInputStream(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		StringBuffer buffer = new StringBuffer();
		byte[] bytes = new byte[1024];
		try {
			for(int n ; (n = input.read(bytes))!=-1 ; ){
				buffer.append(new String(bytes,0,n,"UTF-8"));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return buffer.toString();
	}

	public static String getBody(String val) {
		String start = "<body>";
		String end = "</body>";
		int s = val.indexOf(start) + start.length();
		int e = val.indexOf(end);
		return val.substring(s, e);
	}

	public static String getStyle(String val) {
		String start = "<<style type=\"text/css\">";
		String end = "</style>";
		int s = val.indexOf(start) + start.length();
		int e = val.indexOf(end);
		return val.substring(s, e);
	}


	/**
	 * 关联清表树
	 */
	@GetMapping("/tab-lazytree-all")
	@ApiOperationSupport(order = 14)
	@ApiOperation(value = "关联清表树all", notes = "关联清表树all")
	public R<List<ExceTabTreVO>> tabLazyTreeall(Long modeId,String name, BladeUser bladeUser) {
		List<ExceTabTreVO> tree = excelTabService.tabLazyTreeAll( bladeUser.getTenantId(), modeId, name);
		return R.data(tree);
	}


	/**
	 * 关联清表-保存
	 */
	@GetMapping("/save-linkTab")
	@ApiOperationSupport(order = 14)
	@ApiOperation(value = "关联清表-保存", notes = "关联清表-保存")
	@ApiImplicitParams(value = {
			@ApiImplicitParam(name = "exceTabId", value = "清表id", required = true),
			@ApiImplicitParam(name = "tabId", value = "表Id", required = true)
	})
	public R<List<ExceTabTreVO>> saveLinkeTab(Long exceTabId,Long tabId, BladeUser bladeUser) {
		// 查询私有项目信息
		WbsTreePrivate wbsTree = new WbsTreePrivate();
		wbsTree.setPKeyId(tabId);
		WbsTreePrivate aPrivate = wbsTreePrivateService.getOne(Condition.getQueryWrapper(wbsTree));
		aPrivate.setIsLinkTable(1); // 已关联
		aPrivate.setExcelId(exceTabId);
		wbsTreePrivateService.saveOrUpdate(aPrivate);
		// 解析
		return R.success("关联成功");
	}





	/*public static void main(String[] args) {
		String thmlUrl = "/Users/hongchuangyanfa/Desktop/ToHtml.html";
		String htmlString =  readfile(thmlUrl);
		String htmlBody=  getBody(htmlString);
		Map<String ,String > styleMap = new HashMap<>();

		// 解析 style
		Document doc = Jsoup.parse(htmlString);
		Element style = doc.select("style").first();
		Matcher cssMatcher = Pattern.compile("(\\w+)\\s*[{]([^}]+)[}]").matcher(style.html());
		while (cssMatcher.find()) {
			styleMap.put(cssMatcher.group(1),cssMatcher.group(2));
		}

		// 解析 总行和总列



		// 解析
		Element table = doc.select("table").first();
		Elements trs = table.select("tr");

		// 获取总行列数
		int maxCol = doc.select("Col").size();

		System.out.println(trs.size());
		System.out.println( maxCol );
		List<Map<String,String>> textlist = new ArrayList();

		// 计算 单元格的每个坐标
*//*		for(int i = 0 ;i < trs.size() ;i++) {
			Element tr = trs.get(i);
			Elements tds = tr.select("td");
			int tdw =1;
			for (int j = 0; j < tds.size(); j++) {
				ExctabCell cell = new ExctabCell();
				Element data = tds.get(j);
				String textInfo = data.text();
				int colspan = data.attr("COLSPAN").equals("") ? 1: Integer.parseInt(data.attr("COLSPAN"))-1;
				int rowspan = data.attr("ROWSPAN").equals("") ? 1: Integer.parseInt(data.attr("ROWSPAN"))-1;

				//if(!textInfo.equals("/") && !textInfo.isEmpty()){
					*//**//*Map<String,String> textObject = new HashMap<>();
					textObject.put("text",textInfo);
					textObject.put("x1",tdw+"");
					textObject.put("x2",tdw+colspan+"");
					textObject.put("y1",i+"");
					textObject.put("y2",(i+rowspan)+"");*//**//*
					//textlist.add(textObject);
				//}
//				System.out.print(textInfo +":x1:"+tdw +":x2:"+(tdw+colspan) + "  ");
			}
			System.out.println();
		}*//*

		*//*for(Map<String,String> m:textlist){
			System.out.println(m.get("text")+":"+m.get("x1")+":"+m.get("x2")+":"+m.get("y1")+":"+m.get("y1"));
		}*//*

		for(int i = 0 ;i < trs.size() ;i++){
			Element tr = trs.get(i);
			Elements tds = tr.select("td");
			int tdw =0;
			for( int j = 0 ; j < tds.size();j++ ){
				ExctabCell cell = new ExctabCell();
				Element data = tds.get(j);
				boolean isadd = false ;
				// 更改样式
				String keyId = data.attr("class");
				if(!keyId.isEmpty()){
					data.removeAttr("class");
					data.attr("style",styleMap.get(keyId));
				}

				int colspan = data.attr("COLSPAN").equals("") ? 1: Integer.parseInt(data.attr("COLSPAN"))-1;
				int rowspan = data.attr("ROWSPAN").equals("") ? 1: Integer.parseInt(data.attr("ROWSPAN"))-1;

				// 决定输入啥文本框
				String textInfo = data.text();

				//data

				System.out.println(textInfo + ":" +data.attr("offsetTop"));
				*//*if(textlist.size()>=1){
					for(Map<String,String> m:textlist) {
						int x1 = Integer.parseInt(m.get("x1"));
						int x2 = Integer.parseInt(m.get("x2"));
						int y1 = Integer.parseInt(m.get("y1"));
						int y2 = Integer.parseInt(m.get("y2"));
						System.out.println(m.get("text")+":"+m.get("x1")+":"+m.get("x2")+":"+m.get("y1")+":"+m.get("y2"));


					}
				}else{
					Map<String,String> textObject = new HashMap<>();
					textObject.put("text",textInfo);
					textObject.put("x1",tdw+"");
					textObject.put("x2",tdw+colspan+"");
					textObject.put("y1",(i)+"");
					textObject.put("y2",(i+rowspan)+"");
					textlist.add(textObject);
				}*//*






				*//*if(textInfo.equals("/")|| textInfo.isEmpty()){
					if(i== 0 && j==0 && maxCol==colspan ){ // 第一行为空
						isadd = false;
					}else{
						// 得到 当前位置 获取值
						for(Map<String,String> m:textlist){
							int x1 = Integer.parseInt(m.get("x1"));
							int x2 = Integer.parseInt(m.get("x2"));
							int y1 = Integer.parseInt(m.get("y1"));
							int y2 = Integer.parseInt(m.get("y2"));
							String kekval = m.get("text");

							//||(i>= y1 && (i+rowspan)<=y2 && x2 <tdw && !kekval.isEmpty())
							//(tdw >= x1 && (tdw+colspan)<=x2 && y1<=i && !kekval.isEmpty())

							if((i>= y1 && (i+rowspan)<=y2 && x2 < tdw && !kekval.isEmpty())){ // 向上取值
								System.out.print(i+":"+j);
								System.out.println(":"+m.get("text"));
								isadd = true ;
							}
						}
					}
				}else{
					isadd = false;
				}*//*

				if(isadd){
					data.empty().append("<el-input type='text'  placeholder='请输入内容'> </el-input>");
				}
				tdw = tdw + colspan;
			}
		}

		//System.out.println(table+"");
	}

*/


	/**
	 * 清表生成html
	 */
	@GetMapping("/get-excel-html")
	@ApiOperationSupport(order = 15)
	@ApiOperation(value = "清表生成html", notes = "清表生成html")
	public R getExcelHtml() {
		String thmlUrl = "/Users/hongchuangyanfa/Desktop/ToHtml.html";
		String htmlString =  readfile(thmlUrl);
		String htmlBody=  getBody(htmlString);
		Map<String ,String > styleMap = new HashMap<>();

		// 解析 style
		Document doc = Jsoup.parse(htmlString);
		Element style = doc.select("style").first();
		Matcher cssMatcher = Pattern.compile("(\\w+)\\s*[{]([^}]+)[}]").matcher(style.html());
		while (cssMatcher.find()) {
			styleMap.put(cssMatcher.group(1),cssMatcher.group(2));
		}

		// 解析
		Element table = doc.select("table").first();
		Elements trs = table.select("tr");

		// 获取总行列数
		int maxCol = doc.select("Col").size();

		List<Map<String,String>> textlist = new ArrayList();
		// 计算 单元格的每个坐标
		int trh = 0;
		for(int i = 0 ;i < trs.size() ;i++) {
			Element tr = trs.get(i);
			Elements tds = tr.select("td");
			int tdw =0;
			for (int j = 0; j < tds.size(); j++) {
				ExctabCell cell = new ExctabCell();
				Element data = tds.get(j);
				String textInfo = data.text();
				if(!textInfo.equals("/") && !textInfo.isEmpty()){
					int colspan = Integer.parseInt(data.attr("COLSPAN").equals("")?"0":data.attr("COLSPAN"));
					int rowspan  = Integer.parseInt(data.attr("ROWSPAN").equals("")?"0":data.attr("ROWSPAN"));

					Map<String,String> textObject = new HashMap<>();
					textObject.put("text",textInfo);
					textObject.put("x1",tdw+"");
					tdw = tdw + colspan;
					textObject.put("x2",tdw+"");
					textObject.put("y1",trh+"");
					trh = trh + rowspan;
					textObject.put("y2",trh+"");
					textlist.add(textObject);
				}
			}
		}

	for(Map<String,String> m:textlist){
		System.out.println(m.get("text")+":"+m.get("x1")+":"+m.get("x2")+":"+m.get("y1")+":"+m.get("y1"));
	}

		/*for(int i = 0 ;i < trs.size() ;i++){
			Element tr = trs.get(i);
			Elements tds = tr.select("td");


			for( int j = 0 ; j < tds.size();j++ ){
				ExctabCell cell = new ExctabCell();
				Element data = tds.get(j);

				boolean isadd = false ;

				// 更改样式
				String keyId = data.attr("class");
				if(!keyId.isEmpty()){
					data.removeAttr("class");
					data.attr("style",styleMap.get(keyId));
				}

				int colspan = Integer.parseInt(data.attr("COLSPAN").equals("")?"0":data.attr("COLSPAN"));
				int rowspan  = Integer.parseInt(data.attr("ROWSPAN").equals("")?"0":data.attr("ROWSPAN"));
				// 决定输入啥文本框
				String textInfo = data.text();
				if(textInfo.equals("/")|| textInfo.isEmpty()){
					String trtopval = "";
					String tdleftval = "";
					if(i==0){ // tr 取值
						trtopval = "";
					}else{

					}

					if(j==0){ // tr 取值
						tdleftval = "";
					}else{

					}


				}else{
					isadd = false;
				}

				if(isadd){
					data.empty().append("<el-input type='text'  placeholder=''> </el-input>");
				}
			}
		}*/
		return R.data(table+"");
	}
}
