|
@@ -7,19 +7,17 @@ import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseGrade;
|
|
import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
|
|
+import com.xjrsoft.module.hikvision.entity.HikvisionData;
|
|
|
import com.xjrsoft.module.organization.entity.Department;
|
|
import com.xjrsoft.module.organization.entity.Department;
|
|
|
import com.xjrsoft.module.personnel.entity.CarMessageApply;
|
|
import com.xjrsoft.module.personnel.entity.CarMessageApply;
|
|
|
|
|
+import com.xjrsoft.module.personnel.mapper.TeacherFaceProcessMapper;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
|
|
+import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import lombok.var;
|
|
import lombok.var;
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
import java.sql.SQLException;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.HashSet;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -32,6 +30,8 @@ public class DataUtil {
|
|
|
* 同步组织数据
|
|
* 同步组织数据
|
|
|
* 只有批量添加接口,需要一个层级一个层级的添加
|
|
* 只有批量添加接口,需要一个层级一个层级的添加
|
|
|
*/
|
|
*/
|
|
|
|
|
+ private static FaceImportMapper faceImportMapper;
|
|
|
|
|
+
|
|
|
public Map<String, String> insertDepartment(Db db, String tableName, Map<String, String> tableData) throws Exception {
|
|
public Map<String, String> insertDepartment(Db db, String tableName, Map<String, String> tableData) throws Exception {
|
|
|
String sql = "SELECT DISTINCT LENGTH(hierarchy) FROM " + tableName + " WHERE delete_mark = 0";
|
|
String sql = "SELECT DISTINCT LENGTH(hierarchy) FROM " + tableName + " WHERE delete_mark = 0";
|
|
|
List<Integer[]> list = db.query(sql, Integer[].class);
|
|
List<Integer[]> list = db.query(sql, Integer[].class);
|
|
@@ -453,29 +453,30 @@ public class DataUtil {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*同步车辆数据*/
|
|
/*同步车辆数据*/
|
|
|
- public Map<String, String> insertCar(Db db, String tableName, Map<Long, String> tableData) throws Exception {
|
|
|
|
|
|
|
+ public Map<Long, String> insertCar(Db db, String tableName, Map<Long, String> tableData) throws Exception {
|
|
|
String sql = "SELECT * FROM " + tableName + " WHERE delete_mark = 0 and status = 1";
|
|
String sql = "SELECT * FROM " + tableName + " WHERE delete_mark = 0 and status = 1";
|
|
|
List<CarMessageApply> dataList = db.query(sql, CarMessageApply.class);
|
|
List<CarMessageApply> dataList = db.query(sql, CarMessageApply.class);
|
|
|
String apiPath = "/api/resource/v1/vehicle/batch/add";
|
|
String apiPath = "/api/resource/v1/vehicle/batch/add";
|
|
|
- Map<String, String> idMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Long, String> idMap = new HashMap<>();
|
|
|
JsonParser jsonParser = new JsonParser();
|
|
JsonParser jsonParser = new JsonParser();
|
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
|
|
|
|
|
|
- Map<String, String> idCodeMap = new HashMap<>();
|
|
|
|
|
- idCodeMap.put("tagId", "frs");
|
|
|
|
|
|
|
+ Map<Integer, Long> clientMap = new HashMap<>();
|
|
|
|
|
+ Map<String, String> tagMap = new HashMap<>();
|
|
|
|
|
+ tagMap.put("tagId", "frs");
|
|
|
|
|
+
|
|
|
|
|
+ String sqlHik = "SELECT * FROM " + "hikvision_data" + " WHERE delete_mark = 0 and status = 1";
|
|
|
|
|
+ List<HikvisionData> HikList = db.query(sqlHik, HikvisionData.class);
|
|
|
|
|
|
|
|
JsonArray dataArray = new JsonArray();
|
|
JsonArray dataArray = new JsonArray();
|
|
|
String result = null;
|
|
String result = null;
|
|
|
|
|
+ int clientId = 1;
|
|
|
for (CarMessageApply carMessageApply : dataList) {
|
|
for (CarMessageApply carMessageApply : dataList) {
|
|
|
- long currentTimestamp = System.currentTimeMillis();
|
|
|
|
|
- int randomSuffix = ThreadLocalRandom.current().nextInt(10000);
|
|
|
|
|
- String uniqueClientIdStr = String.format("%03d%04d", currentTimestamp % 1000, randomSuffix);
|
|
|
|
|
- long uniqueClientId = Long.parseLong(uniqueClientIdStr);
|
|
|
|
|
|
|
|
|
|
JsonObject paramJson = new JsonObject();
|
|
JsonObject paramJson = new JsonObject();
|
|
|
- paramJson.addProperty("clientId", uniqueClientId);
|
|
|
|
|
|
|
+ paramJson.addProperty("clientId", clientId);
|
|
|
paramJson.addProperty("plateNo", carMessageApply.getCarNumber());
|
|
paramJson.addProperty("plateNo", carMessageApply.getCarNumber());
|
|
|
- paramJson.addProperty("PersonId",carMessageApply.getUserId());
|
|
|
|
|
|
|
+ paramJson.addProperty("PersonId", faceImportMapper.GetHikvisonPersonId(carMessageApply.getId()));
|
|
|
|
|
|
|
|
int vehicleTypeNum;
|
|
int vehicleTypeNum;
|
|
|
switch (carMessageApply.getVehicleType()) {
|
|
switch (carMessageApply.getVehicleType()) {
|
|
@@ -493,10 +494,11 @@ public class DataUtil {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
paramJson.addProperty("vehicleType", vehicleTypeNum);
|
|
paramJson.addProperty("vehicleType", vehicleTypeNum);
|
|
|
-
|
|
|
|
|
|
|
+ clientMap.put(clientId, carMessageApply.getId());
|
|
|
dataArray.add(paramJson);
|
|
dataArray.add(paramJson);
|
|
|
|
|
+ clientId++;
|
|
|
}
|
|
}
|
|
|
- result = apiUtil.doPost(apiPath, dataArray.toString(), idCodeMap, null);
|
|
|
|
|
|
|
+ result = apiUtil.doPost(apiPath, dataArray.toString(), tagMap, null);
|
|
|
|
|
|
|
|
JsonElement parse = jsonParser.parse(result);
|
|
JsonElement parse = jsonParser.parse(result);
|
|
|
|
|
|
|
@@ -505,7 +507,7 @@ public class DataUtil {
|
|
|
JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
|
|
JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
|
|
|
for (JsonElement jsonElement : array) {
|
|
for (JsonElement jsonElement : array) {
|
|
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
|
- idMap.put(jsonObject.get("clientId").getAsString(), jsonObject.get("vehicleId").getAsString());
|
|
|
|
|
|
|
+ idMap.put(clientMap.get(jsonObject.get("clientId")), jsonObject.get("vehicleId").getAsString());
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
System.err.println("API call failed: " + resultJson.get("msg").getAsString());
|
|
System.err.println("API call failed: " + resultJson.get("msg").getAsString());
|