ソースを参照

计量数据模块增加导入功能

chenwen 1 日 前
コミット
40845fa74c

+ 76 - 0
src/main/java/com/hb/proj/analysis/controller/ProduceParamController.java

@@ -2,7 +2,10 @@ package com.hb.proj.analysis.controller;
 
 import java.io.File;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 import com.hb.proj.allconfig.AccessToken;
 import com.hb.proj.allconfig.BusinessException;
@@ -20,14 +24,21 @@ import com.hb.proj.allconfig.SysLog;
 import com.hb.proj.analysis.service.IPRService;
 import com.hb.proj.analysis.service.ProduceParamCalculator;
 import com.hb.proj.analysis.service.ProduceParamService;
+import com.hb.proj.base.service.WellService;
+import com.hb.proj.excel.imp.ExcelConfig;
+import com.hb.proj.excel.imp.ExcelDataExtractor;
+import com.hb.proj.excel.imp.ExcelResult;
 import com.hb.proj.model.WellAnalysisParamPO;
 import com.hb.proj.model.WellMeasurePO;
 import com.hb.proj.model.WellMeasureVO;
 import com.hb.proj.model.WellPumpPO;
 import com.hb.proj.utils.DownloadUtils;
+import com.hb.proj.utils.JacksonUtils;
+import com.hb.proj.utils.RequestParams;
 import com.hb.proj.utils.RespVO;
 import com.hb.proj.utils.RespVOBuilder;
 import com.hb.xframework.dao.util.PageModel;
+import com.hb.xframework.dao.util.UUIDHexGenerator;
 import com.hb.xframework.util.MapUtils;
 
 import jakarta.servlet.http.HttpServletRequest;
@@ -50,7 +61,72 @@ public class ProduceParamController {
 	@Autowired
 	private IPRService iprService;
 	
+	@Autowired
+	private WellService  wellService;
+	
+	/**
+	 * 测量数据导入
+	 * @param otherParam
+	 * @param file
+	 */
+	@RequestMapping("/importMeasure")
+	public RespVO<Object> importMeasure(RequestParams otherParam,@RequestParam("file") MultipartFile file) {
+		ExcelConfig config=JacksonUtils.get(otherParam.get("config"), ExcelConfig.class);
+		try {
+			ExcelResult importRst=ExcelDataExtractor.getDatas(file.getInputStream(), config);
+			
+			String ignorMsg=processImportData(importRst.getListDatas());
+			
+			
+			service.addMeasureBatch(importRst.getListDatas());
+			
+			Map<String,Object>  rtn=MapUtils.build("checkIgnor",ignorMsg,"validateError",importRst.getError().toString(),"successCount",importRst.getListDatas().size());
+			
+			return RespVOBuilder.ok(rtn);
+		} 
+		catch(BusinessException e) {
+			return RespVOBuilder.error(e.getMessage());
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+			return RespVOBuilder.error("导入出现内部错误");
+		}
+	}
 	
+	/**
+	 * 导入数据处理
+	 * 1.wellName->wellId
+	 * @param datas
+	 */
+	private String  processImportData(List<Map<String,Object>> datas) {
+		if(datas==null || datas.size()==0) {
+			//throw new BusinessException("未提取到符合格式的数据");
+			return null;
+		}
+		Map<String,Object> mapping=wellService.loadWellMapping();
+		if(mapping==null) {
+			mapping=new HashMap<>();
+		}
+		
+		StringBuilder ignorMsg=new StringBuilder();
+		Iterator<Map<String,Object>> iterator=datas.iterator();
+		Map<String,Object> itm=null;
+		UUIDHexGenerator  uuid=UUIDHexGenerator.getInstance();
+		while(iterator.hasNext()){
+			itm=iterator.next();
+			if(!mapping.containsKey(itm.get("wellName").toString().trim())) {
+				ignorMsg.append(itm.get("wellName")+";");
+				iterator.remove();
+			}
+			else {
+				itm.put("wellId", mapping.get(itm.get("wellName")));
+				itm.put("measureId", uuid.generate());
+			}
+		}
+		
+		return ignorMsg.length()>0?ignorMsg.toString():null;
+		
+	}
 	
 	/**
 	 * 下载测量数据导入模板

+ 17 - 1
src/main/java/com/hb/proj/analysis/service/ProduceParamService.java

@@ -1,8 +1,10 @@
 package com.hb.proj.analysis.service;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -12,6 +14,7 @@ import com.hb.proj.model.WellMeasurePO;
 import com.hb.proj.model.WellMeasureVO;
 import com.hb.proj.model.WellPumpPO;
 import com.hb.xframework.dao.core.SpringJdbcDAO;
+import com.hb.xframework.dao.core.UpdateHandler;
 import com.hb.xframework.dao.util.PageModel;
 import com.hb.xframework.dao.util.UUIDHexGenerator;
 
@@ -50,7 +53,7 @@ public class ProduceParamService {
 			sql.append(" and m.create_time <=?");
 			params.add(endTime);
 		}
-		sql.append(" order by m.well_id , m.create_time desc");
+		sql.append(" order by m.well_id , m.start_time desc");
 		
 		return dao.queryForPagedData(sql.toString(),pageNo, pageSize,WellMeasureVO.class,params.toArray());
 	}
@@ -164,6 +167,19 @@ public class ProduceParamService {
 		dao.insert(measure, "tzl_well_measure");
 	}
 	
+	public void addMeasureBatch(List<Map<String,Object>> measures) {
+		if(measures==null || measures.size()==0) {
+			return;
+		}
+		List<String> paramNames=Arrays.asList("measureId","wellId","startTime","waterRatio","meteredLiquidYield");
+		List<Object[]> batchParams=UpdateHandler.generateBatchParams(measures, paramNames, null);
+		String sql="""
+				insert into tzl_well_measure(measure_id,well_id,start_time,water_ratio,metered_liquid_yield,create_time,modify_time,del_if) 
+				values(?,?,?,?,?,now(),now(),0)
+				""";
+		dao.getJdbcTemplate().batchUpdate(sql, batchParams);
+	}
+	
 	/**
 	 * 更新油井测量数据
 	 * @param measure

+ 4 - 0
src/main/java/com/hb/proj/base/service/WellService.java

@@ -49,6 +49,10 @@ public class WellService {
     
     private String tabName="tzl_well";
     
+    public Map<String,Object> loadWellMapping(){
+    	return dao.queryForMapping("select well_name,well_id from tzl_well where del_if=false",  "well_name", "well_id");
+    }
+    
     
     public void saveStatus(String wellId,String status) {
     	dao.exeUpdate("update tzl_well set status=? where well_id=?", status,wellId);

+ 67 - 0
src/main/java/com/hb/proj/excel/imp/CellConfig.java

@@ -0,0 +1,67 @@
+package com.hb.proj.excel.imp;
+
+public class CellConfig {
+
+	private String id;
+	
+	private String name;
+	
+	private String title;
+	
+	private String dataType;
+	
+	private Boolean require=false;
+	
+	private String fmt;
+	
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public String getDataType() {
+		return dataType;
+	}
+
+	public void setDataType(String dataType) {
+		this.dataType = dataType;
+	}
+
+	public Boolean isRequire() {
+		return require;
+	}
+
+	public void setRequire(Boolean require) {
+		this.require = require;
+	}
+
+	public String getFmt() {
+		return fmt;
+	}
+
+	public void setFmt(String fmt) {
+		this.fmt = fmt;
+	}
+
+	
+}

+ 56 - 0
src/main/java/com/hb/proj/excel/imp/ExcelConfig.java

@@ -0,0 +1,56 @@
+package com.hb.proj.excel.imp;
+
+import java.util.List;
+
+public class ExcelConfig {
+
+	private int sheet;  //被导入的数据的sheet索引从0开始,默认为0
+	
+	private String start;  //数据区域的最左上角单元格索引,以excel中的命名方式
+	
+	private String end;
+	
+	private List<CellConfig> block ;  //区块格子
+	
+	private List<CellConfig> cells ;  //零散提取格子
+
+	public int getSheet() {
+		return sheet;
+	}
+
+	public void setSheet(int sheet) {
+		this.sheet = sheet;
+	}
+
+	public String getStart() {
+		return start;
+	}
+
+	public void setStart(String start) {
+		this.start = start;
+	}
+
+	public List<CellConfig> getBlock() {
+		return block;
+	}
+
+	public void setBlock(List<CellConfig> block) {
+		this.block = block;
+	}
+
+	public List<CellConfig> getCells() {
+		return cells;
+	}
+
+	public void setCells(List<CellConfig> cells) {
+		this.cells = cells;
+	}
+
+	public String getEnd() {
+		return end;
+	}
+
+	public void setEnd(String end) {
+		this.end = end;
+	}
+}

+ 213 - 0
src/main/java/com/hb/proj/excel/imp/ExcelDataExtractor.java

@@ -0,0 +1,213 @@
+package com.hb.proj.excel.imp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+
+import com.hb.proj.allconfig.BusinessException;
+
+
+
+
+public class ExcelDataExtractor {
+	
+	/**
+	 * 只支持单文件上传,需要传入template参数
+	 * @param request
+	 * @param response
+	 * @return
+	 * @throws Exception
+	 */
+	
+	/*
+	public static ExcelResult extractExcelData(HttpServletRequest request,MultipartFile file) throws Exception{
+		return extractExcelData(request,file,null);
+	}
+	
+	
+	public static ExcelResult extractExcelData(HttpServletRequest request,MultipartFile file,Map<String,String> otherParams) throws Exception{
+		
+		request.setCharacterEncoding("UTF-8");
+		DiskFileItemFactory factory = new DiskFileItemFactory();
+		factory.setSizeThreshold(10*1024*1024);
+		ServletFileUpload sfu = new ServletFileUpload(factory);
+		sfu.setSizeMax(10*1024 * 1024); // img size 10m
+		List<FileItem> items =null;
+		
+		Map<String,Object> extParams=new HashMap<String,Object>();
+		FileItem uploadFile=sfu.parseRequest(request2);
+		for(FileItem itm : items){
+			if(itm.isFormField()){
+				extParams.put(itm.getFieldName(), itm.getString("UTF-8"));
+			}
+			else{
+				uploadFile=itm;
+			}
+			
+		}
+		if(StringUtils.isEmpty((String)extParams.get("config"))){  //excel配置
+			ExcelResult   excelRst=new ExcelResult();
+			excelRst.setException("缺失导入配置,取消操作");
+			return excelRst;
+		}
+		
+		ExcelConfig config=JacksonUtils.get((String)extParams.get("config"), ExcelConfig.class);
+				
+				
+		
+		ExcelResult er= getDatas(uploadFile, config,request);
+		if(er!=null){
+			er.setReqParams(extParams);
+		}
+		return er;
+	}
+
+	*/
+	
+	public  static ExcelResult getDatas(InputStream is,ExcelConfig config){
+		try {
+			ExcelResult   excelRst=new ExcelResult();
+			Workbook wb=WorkbookFactory.create(is);
+			Sheet sheet = wb.getSheetAt(config.getSheet());
+			List<CellConfig>  cellConfigs=config.getCells();
+			Object[] rsts=null;
+			if(cellConfigs!=null&&cellConfigs.size()>0){
+				for(CellConfig  cc : cellConfigs){
+					rsts=extractCell(sheet,cc);
+					
+					if(StringUtils.isNotEmpty((String)rsts[0])){
+						excelRst.addError((String)rsts[0]);
+					}
+					else{
+						excelRst.addOtherVal(cc.getName(), rsts[1]);
+					}
+				}
+			}
+			cellConfigs=config.getBlock();
+			if(cellConfigs!=null&&cellConfigs.size()>0){
+				extractBlock(sheet,config.getStart(),config.getEnd(),cellConfigs,excelRst);
+			}
+			return excelRst;
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+			throw new BusinessException("解析exel文件出错");
+		}
+		finally {
+			if(is!=null) {
+				try {
+					is.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		
+	
+	}
+	
+	private static Cell getCell(Sheet sheet,CellConfig cellConfig){
+		int[]  indexs=ExcelTool.getIndex(cellConfig.getId());  //基于excel的索引
+		
+		return sheet.getRow(indexs[1]-1).getCell(indexs[0]-1);  //从0开始的索引
+		
+	}
+	
+	private static Object[] extractCell(Sheet sheet,CellConfig cellConfig){
+		Cell cell=getCell(sheet,cellConfig);
+		String val=getCellStringValue(cell,cellConfig.getFmt());
+		return ExcelImportValidator.validate(val, cellConfig.getId(), cellConfig);  //数据验证,通过后进行数据类型转换   //rst[0]:验证结果;rst[1]:转换后的值
+	}
+	
+	private static void extractBlock(Sheet sheet,String start,String end,List<CellConfig>  headers,ExcelResult excelHolder){
+		int[]  startIndexs=ExcelTool.getIndex(start);
+		int[]  endIndexs=ExcelTool.getIndex(end);
+		int starRow=startIndexs[1]; //从1开始计算的
+		int endRow=endIndexs[1];
+		Object[]  rst=null;
+		Map<String,Object>  rowData=null;
+		while(starRow<=endRow&&!isNullRow(sheet.getRow(starRow-1))){
+			rowData=new HashMap<String,Object>();
+			for(CellConfig  cc : headers){
+				cc.setId(cc.getId().replaceAll("\\d+", String.valueOf(starRow))); //更新行号(headers中使用的是首行的行号,需要迭代更换为数据行的行号)
+				rst=extractCell(sheet,cc);
+				
+				if(StringUtils.isNotEmpty((String)rst[0])){
+					excelHolder.addError((String)rst[0]);
+					rowData.clear();
+					break; //只要有一个字段不符合格式要求就不入库
+				}
+				else{
+					rowData.put(cc.getName(), rst[1]);
+				}
+			}
+			if(rowData.size()>0){
+				rowData.put("xlsRowNum", starRow); //add 2024.8.2 
+				excelHolder.addRowVal(rowData);
+				
+			}
+			starRow++;
+		}
+		
+	}
+	
+	
+
+	private static String getCellStringValue(Cell cell,String fmt){
+		if(cell==null){
+			return "";
+		}
+		String cellValue="";
+		switch (cell.getCellType()) {
+		case NUMERIC:
+		case FORMULA: {
+			if (DateUtil.isCellDateFormatted(cell)) {
+				Date date = cell.getDateCellValue();
+				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+				if(fmt!=null && fmt.length() >0) {
+					sdf.applyPattern(fmt);
+				}
+				cellValue = sdf.format(date);
+			} else {
+				DecimalFormat  numdf=new DecimalFormat("#0.######");
+				cellValue=numdf.format(cell.getNumericCellValue());
+			}
+			break;
+		}
+		case STRING:
+			cellValue = cell.getRichStringCellValue().toString().trim();
+			break;
+		default:
+			cellValue="";
+		}
+		
+		return cellValue;
+	}
+	
+	
+	private static boolean isNullRow(Row row){
+		if(row==null){
+			return true;
+		}
+		String val1=getCellStringValue(row.getCell(0),null);
+		String val2=getCellStringValue(row.getCell(1),null);
+		String val3=getCellStringValue(row.getCell(2),null);
+		if("".equals(val1.trim())&&"".equals(val2.trim())&&"".equals(val3.trim())){
+			return true;
+		}
+		return false;
+	}
+}

+ 66 - 0
src/main/java/com/hb/proj/excel/imp/ExcelImpResult.java

@@ -0,0 +1,66 @@
+package com.hb.proj.excel.imp;
+
+public class ExcelImpResult {
+
+	private String unmatchIgnor;  //导入数据中转换为系统内编码时,不匹配而忽略导入的记录提示
+	
+	private String sameIgnor;   //禁止覆盖而忽略导入的记录提示
+	
+	private String validateError; //基于导入配置中的数据校验规则,校验不合格而不导入的提示
+	
+	private int   newImportCount; //新导入记录数
+	
+	private int  coverImportCount; //覆盖入记录数
+	
+	public ExcelImpResult(){
+		
+	}
+	
+	public ExcelImpResult(String unmatchIgnor,String sameIgnor,int newImportCount,int coverImportCount){
+		this.unmatchIgnor=unmatchIgnor;
+		this.sameIgnor=sameIgnor;
+		this.newImportCount=newImportCount;
+		this.coverImportCount=coverImportCount;
+	}
+
+	public String getUnmatchIgnor() {
+		return unmatchIgnor;
+	}
+
+	public void setUnmatchIgnor(String unmatchIgnor) {
+		this.unmatchIgnor = unmatchIgnor;
+	}
+
+	public String getSameIgnor() {
+		return sameIgnor;
+	}
+
+	public void setSameIgnor(String sameIgnor) {
+		this.sameIgnor = sameIgnor;
+	}
+
+	public int getNewImportCount() {
+		return newImportCount;
+	}
+
+	public void setNewImportCount(int newImportCount) {
+		this.newImportCount = newImportCount;
+	}
+
+	public int getCoverImportCount() {
+		return coverImportCount;
+	}
+
+	public void setCoverImportCount(int coverImportCount) {
+		this.coverImportCount = coverImportCount;
+	}
+
+	public String getValidateError() {
+		return validateError;
+	}
+
+	public void setValidateError(String validateError) {
+		this.validateError = validateError;
+	}
+
+}

+ 129 - 0
src/main/java/com/hb/proj/excel/imp/ExcelImportValidator.java

@@ -0,0 +1,129 @@
+package com.hb.proj.excel.imp;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.hb.xframework.util.DateUtil;
+
+public class ExcelImportValidator {
+	
+	public static boolean contains(String src,String regex) {
+		//return extractString(src,regex,0,0)!=null;
+		
+		if(src==null||"".equals(src)||regex==null){
+			return false;
+		}
+		Pattern p=Pattern.compile(regex);
+		Matcher m=p.matcher(src);
+		return m.find(0);
+	}
+
+	/**
+	 * 默认捕获第一个组(从0开始计数)
+	 * @param src
+	 * @param exp
+	 * @return
+	 */
+	public static String extractString(String src,String exp){
+		return extractString(src,exp,0,0);
+	}
+	
+	/**
+	 * 获得指定捕获组(从0开始计数)
+	 * @param src
+	 * @param exp
+	 * @return
+	 */
+	public static String extractString(String src,String exp,int groupIndex,int fromIndex){
+		if(src==null||"".equals(src)||exp==null){
+			return null;
+		}
+		Pattern p=Pattern.compile(exp);
+		Matcher m=p.matcher(src);
+		return m.find(fromIndex)?m.group(groupIndex):null;
+	}
+	
+
+	 public static boolean validate_date(String value,String format){
+	       String yyyyMMdd="^\\d{4}(\\-|\\/)\\d{1,2}(\\-|\\/)\\d{1,2}( (((0|1)[0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9]))?$";
+	       Pattern p = Pattern.compile(yyyyMMdd);
+	 	   Matcher m = p.matcher(value);
+	 	   if(m.matches()){
+	 		   String joinStr=value.indexOf("-")>0?"-":"/";
+	 		   String[] ymd=(value.split(" "))[0].split(joinStr);
+	 		   int mon=Integer.parseInt(ymd[1]);
+	 		   int d=Integer.parseInt(ymd[2]);
+	 		   if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12){
+	 			   return d>0&&d<=31;
+	 		   }
+	 		   else if(mon==2){
+	 			  return d>0&&d<=29;
+	 		   }
+	 		   else if(mon==4||mon==6||mon==9||mon==11) {
+	 			  return d>0&&d<=30;
+	 		   }
+	 		   else{
+	 			   return false;
+	 		   }
+	 	   }
+	       return false;
+			
+		}
+	 
+	 public static boolean validate_int(String value){
+	    	Pattern p = Pattern.compile("^-?\\d+$");
+	  	    Matcher m = p.matcher(value);
+	        return m.matches();
+	 }
+	 
+	 public static boolean validate_number(String value){
+	    	Pattern p = Pattern.compile("^-?\\d+(\\.\\d+)?$");
+	  	    Matcher m = p.matcher(value);
+	        return m.matches();
+	 }
+	 
+	 public static Object[] validate(String value,String cellName,CellConfig rule){
+		    if(rule.isRequire()&&StringUtils.isEmpty(value)){
+	    		return new Object[]{"第"+cellName+"格,"+rule.getTitle()+",不应为空",null};
+	    	}
+		    if(StringUtils.isEmpty(value)){
+		    	return new Object[]{null,null};
+		    }
+	    	boolean rst=true;
+	    	String dataType=rule.getDataType();
+	    	Object valObj=value;
+	    	if("date".equals(dataType)){
+	    		rst=validate_date(value,null);
+	    		if(rst){
+	    			valObj=DateUtil.parse(value);
+	    		}
+	    	}
+	    	else if("int".equals(dataType)){
+	    		rst=validate_int(value);
+	    		if(rst){
+	    			valObj=Integer.parseInt(value);
+	    		}
+	    	}
+	    	else if("number".equals(dataType)){
+	    		rst=validate_number(value);
+	    		if(rst){
+	    			valObj=Double.parseDouble(value);
+	    		}
+	    	}
+	    	else if(dataType.startsWith("notcontains")) {
+	    		String[] dts=dataType.split(":");
+	    		rst=!contains(value, dts[1]);
+	    	}
+	    	else if(dataType.startsWith("contains")) {
+	    		String[] dts=dataType.split(":");
+	    		rst=contains(value, dts[1]);
+	    	}
+	    	if(!rst){
+	    		return new Object[]{"第"+cellName+"格,"+rule.getTitle()+",数据不符合要求",valObj};
+	    	}
+	        return new Object[]{null,valObj};
+	    }
+	    
+}

+ 79 - 0
src/main/java/com/hb/proj/excel/imp/ExcelResult.java

@@ -0,0 +1,79 @@
+package com.hb.proj.excel.imp;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExcelResult {
+
+	private List<Map<String,Object>> listDatas; //区块单元格集值
+	
+	private Map<String,Object>  otherData; //零散的单元格值
+	
+	private Map<String,Object>  reqParams;  //导入时附带的参数
+	
+	private StringBuilder error;
+	
+	//private String exception;
+	
+	
+	public ExcelResult(){
+		this.listDatas=new ArrayList<Map<String,Object>>();
+		this.otherData=new HashMap<String,Object>();
+		this.error=new StringBuilder();
+	}
+
+	public List<Map<String, Object>> getListDatas() {
+		return listDatas;
+	}
+
+	public void setListDatas(List<Map<String, Object>> listDatas) {
+		this.listDatas = listDatas;
+	}
+
+	public Map<String, Object> getOtherData() {
+		return otherData;
+	}
+
+	public void setOtherData(Map<String, Object> otherData) {
+		this.otherData = otherData;
+	}
+
+	public StringBuilder getError() {
+		return error;
+	}
+
+	public void setError(StringBuilder error) {
+		this.error = error;
+	}
+	
+	public void addError(String error){
+		this.error.append(error+";");
+	}
+	
+	public void addOtherVal(String name,Object val){
+		this.otherData.put(name, val);
+	}
+	
+	public void addRowVal(Map<String,Object> record){
+		this.listDatas.add(record);
+	}
+
+	/*
+	public String getException() {
+		return exception;
+	}
+
+	public void setException(String exception) {
+		this.exception = exception;
+	}*/
+
+	public Map<String, Object> getReqParams() {
+		return reqParams;
+	}
+
+	public void setReqParams(Map<String, Object> reqParams) {
+		this.reqParams = reqParams;
+	}
+}

+ 31 - 0
src/main/java/com/hb/proj/excel/imp/ExcelTool.java

@@ -0,0 +1,31 @@
+package com.hb.proj.excel.imp;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.hb.xframework.util.DateUtil;
+
+public class ExcelTool {
+
+	public static int[] getIndex(String columnName){  //columnName=A1
+		if(StringUtils.isEmpty(columnName)){
+			return null;
+		}
+		String[] ary=columnName.toUpperCase().split("\\d+");
+		char[]  chars=ary[0].toCharArray();
+		int c=0;
+		for(int i=chars.length-1,m=0;i>=0;i--,m++){
+			c+=(chars[i]-64)*Math.pow(26, m);
+		}
+		return new int[]{c,Integer.parseInt(columnName.replace(ary[0], ""))};
+	}
+	
+	
+	public static void main(String... args){
+		int[] rst=ExcelTool.getIndex("AA10");
+		System.out.println(rst[0]+":"+rst[1]);
+		Date t=DateUtil.parse("2017-9-8");
+		System.out.println(t.getTime());
+	}
+}