xujiawei 5 роки тому
батько
коміт
22cc0a0e94

+ 19 - 0
src/main/java/edu/nju/controller/ExtraController.java

@@ -9,8 +9,11 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import edu.nju.entities.*;
+import edu.nju.service.RecommendService;
 import org.json.JSONArray;
 import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
@@ -31,6 +34,8 @@ import java.net.URLConnection;
 public class ExtraController {
 	@Autowired
 	ExtraService extraService;
+
+	Logger logger= LoggerFactory.getLogger(RecommendService.class);
 	
 	//上传测试报告
 	@RequestMapping(value = "/uploadReport", method = RequestMethod.POST)
@@ -214,6 +219,17 @@ public class ExtraController {
 	public String uploadExamUrl(String file, String file_name, String paper_type,
 								String case_id, String test_type, String description, String app_name) {
 		try {
+			logger.info(file);
+			logger.info(file_name);
+			logger.info(paper_type);
+			logger.info(case_id);
+			logger.info(test_type);
+			logger.info(description);
+			logger.info(app_name);
+
+//			file=file.replaceAll("59.42.10.17","10.18.18.70");
+
+//			logger.info("修改后fileurl"+file);
 
 			File dest = new File("/Users/hannatao/Downloads/" + file_name);
 			if(!dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); }
@@ -254,8 +270,11 @@ public class ExtraController {
 			bin.close();
 			out.close();
 			String json = extraService.saveExam(case_id, dest.getPath(), app_name, paper_type, test_type, description);
+			logger.info(json);
 			return json;
 		} catch (IOException e) {
+			logger.info("读取excel文件出错");
+			logger.info(e.toString());
 			e.printStackTrace();
 			return "";
 		}

+ 8 - 2
src/main/java/edu/nju/util/ExcelToJson.java

@@ -4,15 +4,18 @@ import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.PrintWriter;
 
+import edu.nju.service.RecommendService;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.json.JSONArray;
 import org.json.JSONObject;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 public class ExcelToJson {
-	
+
+	static Logger logger= LoggerFactory.getLogger(RecommendService.class);
 	@SuppressWarnings("resource")
 	public static JSONArray ExcelTranse(String path) {
 		JSONArray dataArray = new JSONArray();
@@ -81,8 +84,11 @@ public class ExcelToJson {
 			JSONArray array = (JSONArray) dataArray.getJSONObject(dataArray.length()-1).get("children");
 			array.put(second);
 
+			logger.info(dataArray.toString());
 			return dataArray;
 		} catch (Exception e) {
+			logger.info("解析excel出错");
+			logger.info(e.toString());
 			e.printStackTrace();
 			return null;
 		}