|
@@ -5,6 +5,7 @@ import com.mooctest.dao.TaskDao;
|
|
|
import com.mooctest.event.EventUtil;
|
|
|
import com.mooctest.model.ExtendBug;
|
|
|
import com.mooctest.model.Task;
|
|
|
+import com.mooctest.util.ImportDataMap;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
@@ -33,6 +34,9 @@ public class ExcelInputService {
|
|
|
@Autowired
|
|
|
ExtendBugDao extendBugDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ImportDataMap importDataMap;
|
|
|
+
|
|
|
// 接收前端文件,并将MultipartFile文件转换成File文件,并返回文件路径
|
|
|
public String saveMultipartFile(MultipartFile file, String fileSaveName){
|
|
|
OutputStream os = null;
|
|
@@ -70,7 +74,7 @@ public class ExcelInputService {
|
|
|
|
|
|
|
|
|
// 解析File文件,并将为数据库表中各字段赋值,并将数据数据插入数据库中
|
|
|
- public Map<String, Boolean> excelToMongo(String address, String fileSaveName) {
|
|
|
+ public Map<String, Boolean> excelToMongo(String address, String fileSaveName, Integer comeFrom) {
|
|
|
Integer orderId=UUID.randomUUID().toString().hashCode();
|
|
|
orderId = orderId < 0 ? -orderId : orderId;
|
|
|
Long task_id = Long.valueOf(orderId);
|
|
@@ -80,6 +84,41 @@ public class ExcelInputService {
|
|
|
Task task = new Task(task_id, case_id, task_name);
|
|
|
taskDao.save(task);
|
|
|
Map<String, Boolean> insert_map = new HashMap<>();
|
|
|
+ Map<String, String> typeMap = importDataMap.data.get(comeFrom);
|
|
|
+ String appTitle = typeMap.get("title");
|
|
|
+ String appBugCategor = typeMap.get("bug_category");
|
|
|
+ String appSeverity = typeMap.get("severity");
|
|
|
+ String appRecurrent= typeMap.get("recurrent");
|
|
|
+ String appDescription= typeMap.get("description");
|
|
|
+
|
|
|
+
|
|
|
+// InputStream in = ExcelInputService.class.getClassLoader().getResourceAsStream(comeFrom+"-application.properties");
|
|
|
+// //读取文件
|
|
|
+// Properties properties=new Properties();
|
|
|
+// try {
|
|
|
+// properties.load(in);
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+
|
|
|
+// String appTitle = null;
|
|
|
+// String appBugCategor = null;
|
|
|
+// String appSeverity = null;
|
|
|
+// String appRecurrent= null;
|
|
|
+// String appDescription= null;
|
|
|
+// Map<String,String> dataMap = ImportDateMap.data.get("1");
|
|
|
+// dataMap.get("tit")
|
|
|
+// try {
|
|
|
+// appTitle = new String(properties.getProperty("title").getBytes("ISO8859-1"), "GBK");
|
|
|
+// appBugCategor =new String(properties.getProperty("bug_category").getBytes("ISO8859-1"), "GBK");
|
|
|
+// appSeverity = new String(properties.getProperty("severity").getBytes("ISO8859-1"), "GBK");
|
|
|
+// appRecurrent= new String(properties.getProperty("recurrent").getBytes("ISO8859-1"), "GBK");
|
|
|
+// appDescription= new String(properties.getProperty("description").getBytes("ISO8859-1"), "GBK");
|
|
|
+// } catch (UnsupportedEncodingException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println(appTitle);
|
|
|
|
|
|
try {
|
|
|
// 输入文件
|
|
@@ -101,11 +140,14 @@ public class ExcelInputService {
|
|
|
insert_map.put("file_is_null", false);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ System.out.println("ok~~");
|
|
|
for (Cell cell : topRow) {
|
|
|
fieldList.add(cell.toString());
|
|
|
}
|
|
|
|
|
|
logger.info("文件列表" + fieldList);
|
|
|
+ System.out.println("文件列表" + fieldList);
|
|
|
// 获得表单的行数
|
|
|
int rows = sheet.getLastRowNum() + 1;
|
|
|
|
|
@@ -133,7 +175,8 @@ public class ExcelInputService {
|
|
|
for (int j = 0; j < colunms; j++) {
|
|
|
Cell cell = row.getCell(j);
|
|
|
String topName = fieldList.get(j);
|
|
|
- if(topName.equals("title") || topName.equals("题目")){
|
|
|
+// if(topName.equals("title") || topName.equals("题目")){
|
|
|
+ if(topName.equals(appTitle)){
|
|
|
String title;
|
|
|
if(cell == null || cell.toString().equals("")){
|
|
|
title = "空";
|
|
@@ -141,7 +184,8 @@ public class ExcelInputService {
|
|
|
title = cell.toString();
|
|
|
}
|
|
|
extendBug.setTitle(title);
|
|
|
- }else if(topName.equals("bug_category") || topName.equals("分类")){
|
|
|
+// }else if(topName.equals("bug_category") || topName.equals("分类")){
|
|
|
+ }else if(topName.equals(appBugCategor)){
|
|
|
String bug_category;
|
|
|
if(cell == null || cell.toString().equals("")){
|
|
|
bug_category = "空";
|
|
@@ -149,7 +193,8 @@ public class ExcelInputService {
|
|
|
bug_category = cell.toString();
|
|
|
}
|
|
|
extendBug.setBugCategory(bug_category);
|
|
|
- }else if(topName.equals("severity") || topName.equals("严重等级")){
|
|
|
+// }else if(topName.equals("severity") || topName.equals("严重等级")){
|
|
|
+ }else if(topName.equals(appSeverity)){
|
|
|
int num;
|
|
|
if(cell == null || cell.toString().equals("")){
|
|
|
num = 0;
|
|
@@ -158,7 +203,9 @@ public class ExcelInputService {
|
|
|
}
|
|
|
short severity = (short)num;
|
|
|
extendBug.setSeverity(severity);
|
|
|
- }else if(topName.equals("recurrent") || topName.equals("复现程度")){
|
|
|
+// }else if(topName.equals("recurrent") || topName.equals("复现程度")){
|
|
|
+ }else if(topName.equals(appRecurrent)){
|
|
|
+
|
|
|
int num;
|
|
|
if(cell == null || cell.toString().equals("")){
|
|
|
num = 0;
|
|
@@ -167,7 +214,7 @@ public class ExcelInputService {
|
|
|
}
|
|
|
short recurrent = (short)num;
|
|
|
extendBug.setRecurrent(recurrent);
|
|
|
- }else{
|
|
|
+ }else if(topName.equals(appDescription)){
|
|
|
String description;
|
|
|
if(cell == null || cell.toString().equals("")){
|
|
|
description = "空";
|