|
@@ -15,6 +15,8 @@ import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.model.ServiceCode;
|
|
import com.uas.platform.core.model.ServiceCode;
|
|
|
import com.uas.platform.core.model.Status;
|
|
import com.uas.platform.core.model.Status;
|
|
|
|
|
+import com.xiaoleilu.hutool.poi.excel.ExcelReader;
|
|
|
|
|
+import com.xiaoleilu.hutool.poi.excel.ExcelUtil;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
@@ -30,6 +32,7 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author wangyc
|
|
* @author wangyc
|
|
@@ -455,7 +458,42 @@ public class ComponentSubmitController {
|
|
|
}
|
|
}
|
|
|
return componentCrawls;
|
|
return componentCrawls;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上传器件数据到爬虫库(没有参数对应关系)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param uploadItem 文件
|
|
|
|
|
+ * @return 爬取器件信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ @RequestMapping(value = "upload/componentCrawls", method = RequestMethod.POST)
|
|
|
|
|
+ public List<ComponentCrawl> uploadComponentCrawlV2(FileUpload uploadItem) {
|
|
|
|
|
+ String fileName = uploadItem.getFile().getOriginalFilename();
|
|
|
|
|
+ List<ComponentCrawl> componentCrawls = new ArrayList<ComponentCrawl>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ InputStream is = uploadItem.getFile().getInputStream();
|
|
|
|
|
+ ExcelReader reader = ExcelUtil.getReader(is);
|
|
|
|
|
+ List<Map<String, Object>> maps = reader.readAll();
|
|
|
|
|
+
|
|
|
|
|
+ int size = maps.size();
|
|
|
|
|
+ if (size > 10000) {
|
|
|
|
|
+ throw new IllegalOperatorException("上传文件必须小于10000行");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (size > 0) {
|
|
|
|
|
+ Map<String, Object> map = maps.get(0);
|
|
|
|
|
+ if (map.keySet().size() > 28) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ componentCrawls = componentSubmitService.uploadComponentCrawl(maps);
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.log("器件上传", "器件上传");
|
|
|
|
|
+ return componentCrawls;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 上传器件数据到爬虫库(已有参数对应关系)
|
|
* 上传器件数据到爬虫库(已有参数对应关系)
|
|
|
*
|
|
*
|