xiatian 1 年之前
父節點
當前提交
1edb490f2b

+ 10 - 10
src/main/java/cn/com/qmth/importpaper/ClearProp.java

@@ -14,17 +14,17 @@ import okhttp3.Response;
 public class ClearProp {
 
 	private static Logger logger = LogManager.getLogger(ClearProp.class);
-	private static String batch = "230517";
-	private static String host = "https://ynou.exam-cloud.cn";
-	private static String rootOrgId = "17351";
-	private static String key = "U_C_17351_646523";
-	private static String token = "4982461411c04d15a26cc2130a373a6f";
-	
 //	private static String batch = "230517";
-//	private static String host = "http://localhost:8008";
-//	private static String rootOrgId = "149";
-//	private static String key = "U_C_149_170";
-//	private static String token = "cac2f518a68346fe860fcb8a616bb458";
+//	private static String host = "https://ynou.exam-cloud.cn";
+//	private static String rootOrgId = "17351";
+//	private static String key = "U_C_17351_646523";
+//	private static String token = "4982461411c04d15a26cc2130a373a6f";
+	
+	private static String batch = "230517";
+	private static String host = "http://localhost:8008";
+	private static String rootOrgId = "0";
+	private static String key = "$SS:C_0_8";
+	private static String token = "78a3b0a6ea9b43ac8285481fd2df8d80";
 
 	public static void main(String[] args) {
 		logger.debug("**********************开始");

+ 2 - 2
src/main/java/cn/com/qmth/importpaper/DeleteImportPaperQuestion.java

@@ -30,7 +30,7 @@ public class DeleteImportPaperQuestion {
 
 	private static String host = "http://192.168.1.249:8008";
 	private static String key = "U_C_17351_646523";
-	private static String token = "3eb43a9ad3f34bb08f1f2a2e1c7fcbd8";
+	private static String token = "4af5f00976454ab1a6da4d45cfc034c9";
 
 	public static void main(String[] args){
 		logger.debug("**********************删除开始");
@@ -42,7 +42,7 @@ public class DeleteImportPaperQuestion {
 			try {
 				submit(c);
 				index++;
-				logger.debug("**********************完成:" + index);
+				logger.debug("**********************完成:" + index+" | unit_id:"+c.getUnitId() );
 			} catch (IOException e) {
 				logger.error("删除失败:"+c.getUnitId() + " | " + c.getQuestionId(),e);
 			}

+ 0 - 10
src/main/java/cn/com/qmth/importpaper/ImportCourse.java

@@ -5,8 +5,6 @@ import java.util.List;
 
 public class ImportCourse {
 
-	private Long subjectId;
-
 	private String subjectCode;
 
 	private List<Course> courses;
@@ -34,12 +32,4 @@ public class ImportCourse {
 		courses.add(c);
 	}
 
-	public Long getSubjectId() {
-		return subjectId;
-	}
-
-	public void setSubjectId(Long subjectId) {
-		this.subjectId = subjectId;
-	}
-
 }

+ 9 - 9
src/main/java/cn/com/qmth/importpaper/ImportPaperByCourse.java

@@ -12,16 +12,16 @@ public class ImportPaperByCourse {
 
 	private static Logger logger = LogManager.getLogger(ImportPaperByCourse.class);
 	private final static String sourceDir = "d:/yunkai/";
-
-//	private static String host = "http://localhost:8008";
-//	private static String rootOrgId = "149";
-//	private static String key = "U_C_149_170";
-//	private static String token = "cac2f518a68346fe860fcb8a616bb458";
 	
-	private static String host = "http://192.168.1.249:8008";
-	private static String rootOrgId = "17351";
-	private static String key = "U_C_17351_646523";
-	private static String token = "6537edc191d546349fd5a4cb9e74b94b";
+	private static String host = "http://localhost:8008";
+	private static String rootOrgId = "0";
+	private static String key = "$SS:C_0_8";
+	private static String token = "abf51dd054eb4192937d01904a1e966e";
+	
+//	private static String host = "http://192.168.1.249:8008";
+//	private static String rootOrgId = "17351";
+//	private static String key = "U_C_17351_646523";
+//	private static String token = "6537edc191d546349fd5a4cb9e74b94b";
 	
 	private static AtomicInteger count=new AtomicInteger(0);
 

+ 45 - 47
src/main/java/cn/com/qmth/importpaper/ImportPropByCourse.java

@@ -2,7 +2,6 @@ package cn.com.qmth.importpaper;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -27,17 +26,17 @@ public class ImportPropByCourse {
 	private static Logger logger = LogManager.getLogger(ImportPropByCourse.class);
 	private final static String sourceDir = "d:/yunkai/";
 
-//	private static String batch = "230517";
-//	private static String host = "http://localhost:8008";
-//	private static String rootOrgId = "149";
-//	private static String key = "U_C_149_170";
-//	private static String token = "cac2f518a68346fe860fcb8a616bb458";
+	private static String batch = "230821";
 	
-	private static String batch = "230517";
-	private static String host = "http://192.168.1.249:8008";
-	private static String rootOrgId = "17351";
-	private static String key = "U_C_17351_646523";
-	private static String token = "6537edc191d546349fd5a4cb9e74b94b";
+	private static String host = "http://localhost:8008";
+	private static String rootOrgId = "0";
+	private static String key = "$SS:C_0_8";
+	private static String token = "abf51dd054eb4192937d01904a1e966e";
+	
+//	private static String host = "http://192.168.1.249:8008";
+//	private static String rootOrgId = "17351";
+//	private static String key = "U_C_17351_646523";
+//	private static String token = "6537edc191d546349fd5a4cb9e74b94b";
 	
 
 	public static void main(String[] args) {
@@ -47,16 +46,15 @@ public class ImportPropByCourse {
 		StringBuilder sb = new StringBuilder();
 
 		int num = 0;
-		List<Course> cs = readSubject();
+//		List<Course> cs = readSubject();
 		Map<String,ImportCourse> ics=readSubjectCodes();
-		for (Course c : cs) {
-			ImportCourse ic=ics.get(c.getCode());
-			if(ic==null) {
+		for (ImportCourse ic : ics.values()) {
+			File file = new File(sourceDir + "/prop/" + ic.getSubjectCode() + ".json");
+			if(!file.exists()) {
 				continue;
 			}
 			Date n = new Date();
 			num++;
-			File file = new File(sourceDir + "/prop/" + c.getId() + ".json");
 			try {
 				if (file.exists()) {
 					submit(ic, file);
@@ -84,7 +82,7 @@ public class ImportPropByCourse {
 		Map<String,ImportCourse> map=new HashMap<>();
 		XSSFWorkbook wb = null;
 		try {
-			wb = new XSSFWorkbook(sourceDir + "subject_codes.xlsx");
+			wb = new XSSFWorkbook(sourceDir + "subject_info.xlsx");
 			XSSFSheet sheet = wb.getSheetAt(0);
 			int rows = sheet.getLastRowNum();
 			for (int i = 1; i <= rows; i++) {
@@ -117,36 +115,36 @@ public class ImportPropByCourse {
 		return map;
 	}
 	
-	private static List<Course> readSubject() {
-		List<Course> list = new ArrayList<>();
-		XSSFWorkbook wb = null;
-		try {
-			wb = new XSSFWorkbook(sourceDir + "subject.xlsx");
-			XSSFSheet sheet = wb.getSheetAt(0);
-			int rows = sheet.getLastRowNum();
-			for (int i = 1; i <= rows; i++) {
-				Course c = new Course();
-				XSSFRow row = sheet.getRow(i);
-				String id = row.getCell(0).getStringCellValue().trim();
-				String name = row.getCell(1).getStringCellValue().trim();
-				String code = row.getCell(2).getStringCellValue().trim();
-				c.setId(Long.valueOf(id));
-				c.setCode(code);
-				c.setName(name);
-				list.add(c);
-			}
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		} finally {
-			if (wb != null) {
-				try {
-					wb.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-		return list;
-	}
+//	private static List<Course> readSubject() {
+//		List<Course> list = new ArrayList<>();
+//		XSSFWorkbook wb = null;
+//		try {
+//			wb = new XSSFWorkbook(sourceDir + "subject.xlsx");
+//			XSSFSheet sheet = wb.getSheetAt(0);
+//			int rows = sheet.getLastRowNum();
+//			for (int i = 1; i <= rows; i++) {
+//				Course c = new Course();
+//				XSSFRow row = sheet.getRow(i);
+//				String id = row.getCell(0).getStringCellValue().trim();
+//				String name = row.getCell(1).getStringCellValue().trim();
+//				String code = row.getCell(2).getStringCellValue().trim();
+//				c.setId(Long.valueOf(id));
+//				c.setCode(code);
+//				c.setName(name);
+//				list.add(c);
+//			}
+//		} catch (IOException e) {
+//			throw new RuntimeException(e);
+//		} finally {
+//			if (wb != null) {
+//				try {
+//					wb.close();
+//				} catch (IOException e) {
+//				}
+//			}
+//		}
+//		return list;
+//	}
 
 	private static void submit(ImportCourse ic, File zfile) throws Exception {
 		List<String> cs=ic.getCourses().stream().map(e->e.getCode()).collect(Collectors.toList());

+ 2 - 2
src/main/java/cn/com/qmth/importpaper/MyConsumer.java

@@ -25,11 +25,11 @@ public class MyConsumer extends Consumer<ConsumerDto> {
 		ImportPaperByCourse.addDisposeCount();
 	}
 	private  void importCoursePaper(ConsumerDto dto){
-		File file = new File(dto.getSourceDir() + "paper/" + dto.getIc().getSubjectId() + "/");
+		File file = new File(dto.getSourceDir() + "paper/" + dto.getIc().getSubjectCode() + "/");
 		if(!file.exists()) {
 			return;
 		}
-		File zfile = new File(dto.getSourceDir()+"paper/"+dto.getIc().getSubjectId()+ ".zip");
+		File zfile = new File(dto.getSourceDir()+"paper/"+dto.getIc().getSubjectCode()+ ".zip");
 		try {
 			List<File> files = new ArrayList<>();
 			getPaperFile(file, files);

+ 35 - 43
src/main/java/cn/com/qmth/importpaper/MyProducer.java

@@ -1,12 +1,9 @@
 package cn.com.qmth.importpaper;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.collections4.CollectionUtils;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -28,20 +25,15 @@ public class MyProducer extends Producer {
 		String rootOrgId=param.get("rootOrgId").toString();
 		String key=param.get("key").toString();
 		String token=param.get("token").toString();
-		List<Course> cs = readSubject();
+//		List<Course> cs = readSubject();
 		Map<String,ImportCourse> ics=readSubjectCodes();
-		if (CollectionUtils.isEmpty(cs)) {
+		if (ics.size()==0) {
 			logger.debug("无数据导入");
 			return;
 		} else {
-			logger.debug(cs.size() + "个课程");
+			logger.debug(ics.size() + "个课程");
 		}
-		for (Course c : cs) {
-			ImportCourse ic=ics.get(c.getCode());
-			if(ic==null) {
-				continue;
-			}
-			ic.setSubjectId(c.getId());
+		for (ImportCourse ic : ics.values()) {
 			offer(new ConsumerDto(ic, sourceDir, host, rootOrgId, key, token));
 		}
 		logger.info("***************************任务生产结束");
@@ -51,7 +43,7 @@ public class MyProducer extends Producer {
 		Map<String,ImportCourse> map=new HashMap<>();
 		XSSFWorkbook wb = null;
 		try {
-			wb = new XSSFWorkbook(sourceDir + "subject_codes.xlsx");
+			wb = new XSSFWorkbook(sourceDir + "subject_info.xlsx");
 			XSSFSheet sheet = wb.getSheetAt(0);
 			int rows = sheet.getLastRowNum();
 			for (int i = 1; i <= rows; i++) {
@@ -84,34 +76,34 @@ public class MyProducer extends Producer {
 		return map;
 	}
 	
-	private  List<Course> readSubject() {
-		List<Course> list = new ArrayList<>();
-		XSSFWorkbook wb = null;
-		try {
-			wb = new XSSFWorkbook(sourceDir + "subject.xlsx");
-			XSSFSheet sheet = wb.getSheetAt(0);
-			int rows = sheet.getLastRowNum();
-			for (int i = 1; i <= rows; i++) {
-				Course c = new Course();
-				XSSFRow row = sheet.getRow(i);
-				String id = row.getCell(0).getStringCellValue().trim();
-				String name = row.getCell(1).getStringCellValue().trim();
-				String code = row.getCell(2).getStringCellValue().trim();
-				c.setId(Long.valueOf(id));
-				c.setCode(code);
-				c.setName(name);
-				list.add(c);
-			}
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		} finally {
-			if (wb != null) {
-				try {
-					wb.close();
-				} catch (IOException e) {
-				}
-			}
-		}
-		return list;
-	}
+//	private  List<Course> readSubject() {
+//		List<Course> list = new ArrayList<>();
+//		XSSFWorkbook wb = null;
+//		try {
+//			wb = new XSSFWorkbook(sourceDir + "subject.xlsx");
+//			XSSFSheet sheet = wb.getSheetAt(0);
+//			int rows = sheet.getLastRowNum();
+//			for (int i = 1; i <= rows; i++) {
+//				Course c = new Course();
+//				XSSFRow row = sheet.getRow(i);
+//				String id = row.getCell(0).getStringCellValue().trim();
+//				String name = row.getCell(1).getStringCellValue().trim();
+//				String code = row.getCell(2).getStringCellValue().trim();
+//				c.setId(Long.valueOf(id));
+//				c.setCode(code);
+//				c.setName(name);
+//				list.add(c);
+//			}
+//		} catch (IOException e) {
+//			throw new RuntimeException(e);
+//		} finally {
+//			if (wb != null) {
+//				try {
+//					wb.close();
+//				} catch (IOException e) {
+//				}
+//			}
+//		}
+//		return list;
+//	}
 }