|
@@ -24,23 +24,12 @@ import okhttp3.Response;
|
|
|
public class ImportPropByCourse {
|
|
|
|
|
|
private static Logger logger = LogManager.getLogger(ImportPropByCourse.class);
|
|
|
- private final static String sourceDir = "d:/yunkai/";
|
|
|
|
|
|
//课程属性批次号
|
|
|
//批次号相同时,同一数据可执行重复导入
|
|
|
//此值不要修改。因为第一次导入230517批次的时候未保存批次信息,所以230517批次的不能共用。第二次导入230821批次的保存了批次值,可以后续公用。
|
|
|
private final static String batch = "230821";
|
|
|
|
|
|
-// private static String host = "http://192.168.10.145:8008";
|
|
|
-// private static String rootOrgId = "149";
|
|
|
-// private static String key = "$SS:C_149_170";
|
|
|
-// private static String token = "83540688f3ff4aebbaf1f98e1e77f17c";
|
|
|
-
|
|
|
- private static String host = "http://192.168.1.249:8008";
|
|
|
- private static String rootOrgId = "17351";
|
|
|
- private static String key = "$SS:C_17351_646523";
|
|
|
- private static String token = "95c77664d77f4ba6b58b940ab5e633c8";
|
|
|
-
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
logger.debug("**********************导入开始");
|
|
@@ -50,9 +39,9 @@ public class ImportPropByCourse {
|
|
|
|
|
|
int num = 0;
|
|
|
// List<Course> cs = readSubject();
|
|
|
- Map<String,ImportCourse> ics=readSubjectCodes();
|
|
|
- for (ImportCourse ic : ics.values()) {
|
|
|
- File file = new File(sourceDir + "/prop/" + ic.getSubjectCode() + ".json");
|
|
|
+ Map<String,CourseDto> ics=readSubjectCodes();
|
|
|
+ for (CourseDto ic : ics.values()) {
|
|
|
+ File file = new File(Param.dataDir + "/prop/" + ic.getSubjectCode() + ".json");
|
|
|
if(!file.exists()) {
|
|
|
continue;
|
|
|
}
|
|
@@ -81,11 +70,11 @@ public class ImportPropByCourse {
|
|
|
OKHttpUtil.close();
|
|
|
}
|
|
|
|
|
|
- private static Map<String,ImportCourse> readSubjectCodes() {
|
|
|
- Map<String,ImportCourse> map=new HashMap<>();
|
|
|
+ private static Map<String,CourseDto> readSubjectCodes() {
|
|
|
+ Map<String,CourseDto> map=new HashMap<>();
|
|
|
XSSFWorkbook wb = null;
|
|
|
try {
|
|
|
- wb = new XSSFWorkbook(sourceDir + "subject_info.xlsx");
|
|
|
+ wb = new XSSFWorkbook(Param.dataDir + "/subject_info.xlsx");
|
|
|
XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
int rows = sheet.getLastRowNum();
|
|
|
for (int i = 1; i <= rows; i++) {
|
|
@@ -101,9 +90,9 @@ public class ImportPropByCourse {
|
|
|
String name = row.getCell(2).getStringCellValue().trim();
|
|
|
c.setCode(ecCode);
|
|
|
c.setName(name);
|
|
|
- ImportCourse ic=map.get(yunCode);
|
|
|
+ CourseDto ic=map.get(yunCode);
|
|
|
if(ic==null) {
|
|
|
- ic=new ImportCourse();
|
|
|
+ ic=new CourseDto();
|
|
|
ic.setSubjectCode(yunCode);
|
|
|
map.put(yunCode,ic);
|
|
|
}
|
|
@@ -154,21 +143,21 @@ public class ImportPropByCourse {
|
|
|
// return list;
|
|
|
// }
|
|
|
|
|
|
- private static void submit(ImportCourse ic, File zfile) throws Exception {
|
|
|
+ private static void submit(CourseDto ic, File zfile) throws Exception {
|
|
|
List<String> cs=ic.getCourses().stream().map(e->e.getCode()).collect(Collectors.toList());
|
|
|
Map<String, String> params = Maps.newHashMap();
|
|
|
- params.put("rootOrgId", rootOrgId);
|
|
|
+ params.put("rootOrgId", Param.rootOrgId);
|
|
|
params.put("batch", batch);
|
|
|
params.put("courseCodes", StringUtils.join(cs,","));
|
|
|
Map<String, String> headers = Maps.newHashMap();
|
|
|
- headers.put("key", key);
|
|
|
- headers.put("token", token);
|
|
|
+ headers.put("key", Param.key);
|
|
|
+ headers.put("token", Param.token);
|
|
|
List<FormFilePart> fileList = Lists.newArrayList();
|
|
|
fileList.add(new FormFilePart("dataFile", zfile.getName(), zfile));
|
|
|
Response resp = null;
|
|
|
try {
|
|
|
// OKHttpUtil.initOkHttpClient();
|
|
|
- resp = OKHttpUtil.call(HttpMethod.POST, host + "/api/ecs_ques/importYunkaiProp", headers, params, fileList);
|
|
|
+ resp = OKHttpUtil.call(HttpMethod.POST, Param.host + "/api/ecs_ques/importYunkaiProp", headers, params, fileList);
|
|
|
if (resp.code() != 200) {
|
|
|
throw new Exception(zfile.getName() + ":body:" + resp.body().string());
|
|
|
}
|