|
@@ -7,18 +7,18 @@ import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
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.personnel.entity.CarMessageApply;
|
|
|
-import com.xjrsoft.module.personnel.mapper.TeacherFaceProcessMapper;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import lombok.var;
|
|
|
+import org.apache.velocity.runtime.directive.Foreach;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
|
/**
|
|
|
* @author dzx
|
|
@@ -30,8 +30,6 @@ public class DataUtil {
|
|
|
* 同步组织数据
|
|
|
* 只有批量添加接口,需要一个层级一个层级的添加
|
|
|
*/
|
|
|
- private static FaceImportMapper faceImportMapper;
|
|
|
-
|
|
|
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";
|
|
|
List<Integer[]> list = db.query(sql, Integer[].class);
|
|
@@ -454,10 +452,11 @@ public class DataUtil {
|
|
|
}
|
|
|
|
|
|
/*同步车辆数据*/
|
|
|
- public Map<Long, String> insertCar(Db db, String tableName, Map<Long, String> tableData) throws Exception {
|
|
|
+ public Map<Long, String> insertCar(Db db, String tableName, Map<String, String> tableData, FaceImportMapper faceImportMapper) throws Exception {
|
|
|
String sql = "SELECT * FROM " + tableName + " WHERE delete_mark = 0 and status = 1";
|
|
|
List<CarMessageApply> dataList = db.query(sql, CarMessageApply.class);
|
|
|
String apiPath = "/api/resource/v1/vehicle/batch/add";
|
|
|
+ String apiPathTime = "/api/pms/v1/car/charge";
|
|
|
Map<Long, String> idMap = new HashMap<>();
|
|
|
JsonParser jsonParser = new JsonParser();
|
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
@@ -466,18 +465,25 @@ public class DataUtil {
|
|
|
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);
|
|
|
+ String existingPlatesSql = "SELECT source_id FROM hikvision_data";
|
|
|
+ List<String> existingPlates = db.query(existingPlatesSql, String.class);
|
|
|
+
|
|
|
+ for (String h : existingPlates){
|
|
|
+ System.out.println(h + "qqq");
|
|
|
+ }
|
|
|
|
|
|
JsonArray dataArray = new JsonArray();
|
|
|
String result = null;
|
|
|
int clientId = 1;
|
|
|
for (CarMessageApply carMessageApply : dataList) {
|
|
|
+ if(tableData != null && tableData.containsKey(existingPlates.get(clientId - 1))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
JsonObject paramJson = new JsonObject();
|
|
|
paramJson.addProperty("clientId", clientId);
|
|
|
paramJson.addProperty("plateNo", carMessageApply.getCarNumber());
|
|
|
- paramJson.addProperty("PersonId", faceImportMapper.GetHikvisonPersonId(carMessageApply.getId()));
|
|
|
+ paramJson.addProperty("personId", faceImportMapper.GetHikvisonPersonId(Long.valueOf(Long.parseLong(carMessageApply.getId().toString()))));
|
|
|
|
|
|
int vehicleTypeNum;
|
|
|
switch (carMessageApply.getVehicleType()) {
|
|
@@ -501,20 +507,33 @@ public class DataUtil {
|
|
|
}
|
|
|
result = apiUtil.doPost(apiPath, dataArray.toString(), tagMap, null);
|
|
|
|
|
|
- JsonElement parse = jsonParser.parse(result);
|
|
|
+ for (CarMessageApply carMessageApply : dataList) {
|
|
|
+ JsonObject paramJsonTime = new JsonObject();
|
|
|
+ paramJsonTime.addProperty("parkSyscode", "c69f2a7c48a74216bcab7d65f24d4a09");
|
|
|
+ paramJsonTime.addProperty("plateNo", carMessageApply.getCarNumber());
|
|
|
+ paramJsonTime.addProperty("startTime", String.valueOf(carMessageApply.getStartTime()));
|
|
|
+ paramJsonTime.addProperty("endTime", String.valueOf(carMessageApply.getEndTime()));
|
|
|
+ String aa = apiUtil.doPost(apiPathTime, String.valueOf(paramJsonTime), tagMap, null);
|
|
|
+ }
|
|
|
|
|
|
+ JsonElement parse = jsonParser.parse(result);
|
|
|
JsonObject resultJson = parse.getAsJsonObject();
|
|
|
if ("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())) {
|
|
|
JsonArray array = resultJson.get("data").getAsJsonObject().get("successes").getAsJsonArray();
|
|
|
for (JsonElement jsonElement : array) {
|
|
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
|
- idMap.put(clientMap.get(jsonObject.get("clientId")), jsonObject.get("vehicleId").getAsString());
|
|
|
+ int responseClientId = jsonObject.get("clientId").getAsInt();
|
|
|
+ Long sourceId = clientMap.get(responseClientId);
|
|
|
+ if (sourceId != null) {
|
|
|
+ idMap.put(sourceId, jsonObject.get("vehicleId").getAsString());
|
|
|
+ } else {
|
|
|
+ System.err.println("No matching clientId found in clientMap for: " + responseClientId);
|
|
|
+ }
|
|
|
}
|
|
|
+ insertRecord(db, tableName, idMap);
|
|
|
} else {
|
|
|
System.err.println("API call failed: " + resultJson.get("msg").getAsString());
|
|
|
}
|
|
|
-
|
|
|
- insertRecord(db, tableName, idMap);
|
|
|
return idMap;
|
|
|
}
|
|
|
|