deason 6 ヶ月 前
コミット
867a62be20

+ 30 - 4
src/main/java/cn/com/qmth/examcloud/tool/service/CommonService.java

@@ -18,7 +18,10 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Component
 public class CommonService {
@@ -103,7 +106,7 @@ public class CommonService {
             String url = loginUser.getServerUrl() + "/api/ecs_core/course/byCode";
             result = HttpHelper.get(url, headers, params);
         } catch (Exception e) {
-            log.error(e.getMessage());
+            log.error("courseCode:{} {}", courseCode, e.getMessage());
             return null;
         }
 
@@ -129,6 +132,29 @@ public class CommonService {
         headers.put("token", loginUser.getToken());
 
         Map<String, String> params = new HashMap<>();
+        params.put("rootOrgId", String.valueOf(loginUser.getRootOrgId()));
+        params.put("code", orgCode);
+
+        String result;
+        try {
+            String url = loginUser.getServerUrl() + "/api/ecs_core/org/byCode";
+            result = HttpHelper.get(url, headers, params);
+        } catch (Exception e) {
+            log.error("orgCode:{} {}", orgCode, e.getMessage());
+            return null;
+        }
+
+        JsonNode value = new JsonMapper().getNode(result);
+        if (value == null) {
+            return null;
+        }
+
+        String id = value.get("id").asText();
+        if (StringUtils.isNotEmpty(id)) {
+            return Long.parseLong(id);
+        }
+
+        /*Map<String, String> params = new HashMap<>();
         params.put("parentId", String.valueOf(loginUser.getRootOrgId()));
         params.put("code", orgCode);
 
@@ -137,7 +163,7 @@ public class CommonService {
             String url = loginUser.getServerUrl() + "/api/ecs_core/org/subOrgPage/0/5";
             result = HttpHelper.get(url, headers, params);
         } catch (Exception e) {
-            log.error(e.getMessage());
+            log.error("orgCode:{} {}", orgCode, e.getMessage());
             return null;
         }
 
@@ -155,7 +181,7 @@ public class CommonService {
                     return node.get("id").asLong();
                 }
             }
-        }
+        }*/
 
         return null;
     }

+ 3 - 2
src/test/java/cn/com/qmth/examcloud/tool/ToolTest.java

@@ -68,11 +68,12 @@ public class ToolTest {
 
     private void testTask(User loginUser) {
         Map<String, Object> params = new HashMap<>();
-        params.put("examId", 0);
-        params.put("dataFilePath", DATA_DIR + "/批量导入考生模板.xlsx");
+        params.put("examId", 89);
+        params.put("dataFilePath", DATA_DIR + "/考生导入模板-1w.xlsx");
         // params.put("dataFilePath", DATA_DIR + "/批量创建用户模板.xlsx");
 
         TaskEntity task = new TaskEntity();
+        task.setId(System.currentTimeMillis());
         task.setUserToken(loginUser.getToken());
         task.setParams(new JsonMapper().toJson(params));