|
@@ -14,6 +14,7 @@ import com.xjrsoft.module.hikvision.util.DataUtil;
|
|
|
import com.xjrsoft.module.organization.entity.Department;
|
|
|
import com.xjrsoft.module.schedule.entity.JianyueData;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
+import lombok.var;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@@ -82,19 +83,34 @@ class HikvisionBaseDataTaskTest {
|
|
|
tableName = "base_student";
|
|
|
Map<String, String> baseStudent = dataMap.get(tableName);
|
|
|
Map<String, String> student = insertStudentOne(use, tableName, baseStudent);
|
|
|
+
|
|
|
+// selectOrg(use, "base_class");
|
|
|
}
|
|
|
|
|
|
+ public static void insertRecord(Db db, String tableName, Map<?, String> idsMap) throws SQLException {
|
|
|
+ if (idsMap.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var sqls = new ArrayList<String>();
|
|
|
+ for (var entry : idsMap.entrySet()) {
|
|
|
+ var sourceId = entry.getKey();
|
|
|
+ var sql = "INSERT INTO hikvision_data(create_date, table_name, source_id, hikvision_id) " +
|
|
|
+ "VALUES(now(), '" + tableName + "', '" + sourceId + "', '" + entry.getValue() + "')";
|
|
|
+ sqls.add(sql);
|
|
|
+ }
|
|
|
+ db.executeBatch(sqls);
|
|
|
+ }
|
|
|
|
|
|
public Map<String, String> insertStudentOne(Db db, String tableName, Map<String, String> tableData) throws Exception {
|
|
|
String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',t4.name,'-',t3.class_type,'-',t2.stduy_status)," +
|
|
|
" t1.user_name,t1.gender,DATE_FORMAT(t1.birth_date, '%Y-%m-%d'),t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
|
|
|
" INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
|
|
|
" INNER JOIN base_class t3 ON t2.class_id = t3.id" +
|
|
|
- " INNER JOIN base_grade t4 ON t2.grade_id = t4.id" +
|
|
|
+ " INNER JOIN base_grade t4 ON t3.grade_id = t4.id" +
|
|
|
" WHERE t1.delete_mark = 0 AND t2.delete_mark = 0" +
|
|
|
" AND t3.class_type IS NOT NULL" +
|
|
|
" AND t1.id NOT IN (SELECT source_id FROM hikvision_data WHERE table_name = 'base_student'\n" +
|
|
|
- ")";
|
|
|
+ ") AND t4.name NOT IN ('2021级','2020级')";
|
|
|
List<String[]> list = db.query(sql, String[].class);
|
|
|
Map<Integer, String> clientMap = new HashMap<>();
|
|
|
|
|
@@ -145,7 +161,7 @@ class HikvisionBaseDataTaskTest {
|
|
|
idMap.put(el[0], array.get("personId").getAsString());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ insertRecord(db, tableName, idMap);
|
|
|
//插入记录表
|
|
|
return idMap;
|
|
|
}
|
|
@@ -200,18 +216,6 @@ class HikvisionBaseDataTaskTest {
|
|
|
|
|
|
|
|
|
|
|
|
- void insertRecord(Db db, String tableName, Map<Long, String> idsMap) throws SQLException {
|
|
|
- if(idsMap.isEmpty()){
|
|
|
- return;
|
|
|
- }
|
|
|
- List<String> sqls = new ArrayList<>();
|
|
|
- for (Long sourceId : idsMap.keySet()) {
|
|
|
- String sql = "INSERT INTO hikvision_data(create_date,table_name,source_id,hikvision_id) value(now(),'"
|
|
|
- + tableName + "'," + sourceId + ",'" + idsMap.get(sourceId) + "')";
|
|
|
- sqls.add(sql);
|
|
|
- }
|
|
|
- db.executeBatch(sqls);
|
|
|
- };
|
|
|
|
|
|
void selecAllPersonById(Db db) throws SQLException {
|
|
|
String apiPath = "/api/resource/v2/person/advance/personList";
|