package com.taover.bazhuayun.analysis.script.goodscollect; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import com.taover.bazhuayun.analysis.util.ExcelUtil; import com.taover.util.UtilString; public class GoodsDataFileParser { private String fileNameIgnorePreffix; private StringBuffer logStrBuffer = new StringBuffer(); private Set rowSet = new HashSet(); private String[] goodsNamePatternArr; private String[] goodsSkuNameParrternArr; private GroupInfoExcelData groupInfoData; public GoodsDataFileParser(String[] goodsNamePatternArr, String[] goodsSkuNameParrternArr, GroupInfoExcelData groupInfoData) { this.goodsNamePatternArr = goodsNamePatternArr; this.goodsSkuNameParrternArr = goodsSkuNameParrternArr; this.groupInfoData = groupInfoData; } public void setFileNameIgnorePreffix(String preffix) { this.fileNameIgnorePreffix = preffix; } public void parse(GroupInfoExcelData groupInfoData, File[] listFiles) throws Exception { for(int i=0; i> data = ExcelUtil.readExcelSheet(item, false); if(data.isEmpty()) { return; } //计算起始行及表头索引 int headerRowIndex = 0; GoodsInfoExcelDataHeader header = null; while(headerRowIndex tempHeaderData = data.get(headerRowIndex); if(this.notBlankDataCount(tempHeaderData) < 3) { ++headerRowIndex; continue; } header = new GoodsInfoExcelDataHeader(this.goodsNamePatternArr, this.goodsSkuNameParrternArr, tempHeaderData); if(!header.available()) { this.logStrBuffer.append("ERROR:没找到商品列或规格列\n"); return; } break; } //写入结果集 for(int j=headerRowIndex+1; j tempHeaderData) { if(tempHeaderData == null || tempHeaderData.isEmpty()) { return 0; } int count = 0; for(int i=0; i getResult() { List data = new ArrayList(); Iterator rowIter = this.rowSet.iterator(); while(rowIter.hasNext()) { data.add(rowIter.next()); } Collections.sort(data); return data; } public String getLogString() { return logStrBuffer.toString(); } }