|
|
@@ -10,17 +10,15 @@ import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
import com.xjrsoft.module.organization.entity.Department;
|
|
|
import com.xjrsoft.module.personnel.entity.CarMessageApply;
|
|
|
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.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.concurrent.ThreadLocalRandom;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author dzx
|
|
|
@@ -148,7 +146,7 @@ public class DataUtil {
|
|
|
paramJson.addProperty("parentIndexCode", status);
|
|
|
paramJson.addProperty("orgCode", dict.getCode());
|
|
|
dataArray.add(paramJson);
|
|
|
- idCodeMap.put(clientId, dict.getCode());
|
|
|
+ idCodeMap.put(clientId, dict.getCode() + "-" + status);
|
|
|
clientId ++;
|
|
|
}
|
|
|
}
|
|
|
@@ -172,18 +170,18 @@ public class DataUtil {
|
|
|
dataArray = new JsonArray();
|
|
|
for (String classType : classTypeSet) {
|
|
|
for (BaseGrade baseGrade : gradeList) {
|
|
|
- gradeNameMap.put(baseGrade.getId(), baseGrade.getName());
|
|
|
+ gradeNameMap.put(baseGrade.getId(), baseGrade.getName().replaceAll("级", ""));
|
|
|
if(tableData != null && tableData.containsKey(baseGrade.getId().toString())){
|
|
|
continue;
|
|
|
}
|
|
|
JsonObject paramJson = new JsonObject();
|
|
|
paramJson.addProperty("clientId", clientId);
|
|
|
- paramJson.addProperty("orgIndexCode", baseGrade.getName() + "-" + classType);
|
|
|
+ paramJson.addProperty("orgIndexCode", baseGrade.getName().replaceAll("级", "") + "-" + classType);
|
|
|
paramJson.addProperty("orgName", baseGrade.getName());
|
|
|
paramJson.addProperty("parentIndexCode", classType);
|
|
|
paramJson.addProperty("orgCode", clientId);
|
|
|
dataArray.add(paramJson);
|
|
|
- idCodeMap.put(clientId, baseGrade.getName());
|
|
|
+ idCodeMap.put(clientId, baseGrade.getName().replaceAll("级", "") + "-" + classType);
|
|
|
clientId ++;
|
|
|
}
|
|
|
}
|
|
|
@@ -227,7 +225,7 @@ public class DataUtil {
|
|
|
paramJson.addProperty("parentIndexCode", grade);
|
|
|
paramJson.addProperty("orgCode", clientId);
|
|
|
dataArray.add(paramJson);
|
|
|
- idCodeMap.put(clientId, baseClass.getId().toString());
|
|
|
+ idCodeMap.put(clientId, baseClass.getId() + "-" + grade);
|
|
|
clientId ++;
|
|
|
}
|
|
|
}
|
|
|
@@ -250,7 +248,7 @@ public class DataUtil {
|
|
|
}
|
|
|
|
|
|
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)," +
|
|
|
+ String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',replace(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" +
|
|
|
@@ -296,6 +294,7 @@ public class DataUtil {
|
|
|
paramJson.addProperty("gender", gender);
|
|
|
|
|
|
clientMap.put(i, el[0]);
|
|
|
+ System.out.println("入参:" + paramJson.toString());
|
|
|
String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
|
|
|
JsonElement parse = jsonParser.parse(result);
|
|
|
JsonObject resultJson = parse.getAsJsonObject();
|
|
|
@@ -453,29 +452,38 @@ 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<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";
|
|
|
- Map<String, String> idMap = new HashMap<>();
|
|
|
+ String apiPathTime = "/api/pms/v1/car/charge";
|
|
|
+ Map<Long, String> idMap = new HashMap<>();
|
|
|
JsonParser jsonParser = new JsonParser();
|
|
|
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 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) {
|
|
|
- long currentTimestamp = System.currentTimeMillis();
|
|
|
- int randomSuffix = ThreadLocalRandom.current().nextInt(10000);
|
|
|
- String uniqueClientIdStr = String.format("%03d%04d", currentTimestamp % 1000, randomSuffix);
|
|
|
- long uniqueClientId = Long.parseLong(uniqueClientIdStr);
|
|
|
+ if(tableData != null && tableData.containsKey(existingPlates.get(clientId - 1))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
JsonObject paramJson = new JsonObject();
|
|
|
- paramJson.addProperty("clientId", uniqueClientId);
|
|
|
+ paramJson.addProperty("clientId", clientId);
|
|
|
paramJson.addProperty("plateNo", carMessageApply.getCarNumber());
|
|
|
- paramJson.addProperty("PersonId",carMessageApply.getUserId());
|
|
|
+ paramJson.addProperty("personId", faceImportMapper.GetHikvisonPersonId(Long.valueOf(Long.parseLong(carMessageApply.getId().toString()))));
|
|
|
|
|
|
int vehicleTypeNum;
|
|
|
switch (carMessageApply.getVehicleType()) {
|
|
|
@@ -493,25 +501,39 @@ public class DataUtil {
|
|
|
break;
|
|
|
}
|
|
|
paramJson.addProperty("vehicleType", vehicleTypeNum);
|
|
|
-
|
|
|
+ clientMap.put(clientId, carMessageApply.getId());
|
|
|
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);
|
|
|
+ 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(jsonObject.get("clientId").getAsString(), 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;
|
|
|
}
|
|
|
|