|
|
@@ -13,7 +13,6 @@ import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import lombok.var;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.sql.SQLException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
@@ -52,7 +51,7 @@ public class DataUtil {
|
|
|
for (Integer level : levelSet) {
|
|
|
JsonArray dataArray = new JsonArray();
|
|
|
for (Department department : dataList) {
|
|
|
- if(tableData.containsKey(department.getId().toString())){
|
|
|
+ if(tableData != null && tableData.containsKey(department.getId().toString())){
|
|
|
continue;
|
|
|
}
|
|
|
if(department.getHierarchy().length() == level){
|
|
|
@@ -250,13 +249,74 @@ public class DataUtil {
|
|
|
return idMap;
|
|
|
}
|
|
|
|
|
|
+ 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" +
|
|
|
+ " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND t3.class_type IS NOT NULL";
|
|
|
+ List<String[]> list = db.query(sql, String[].class);
|
|
|
+ Map<Integer, String> clientMap = new HashMap<>();
|
|
|
+
|
|
|
+ String apiPath = "/api/resource/v2/person/single/add";
|
|
|
+ Map<String, String> idMap = new HashMap<>();
|
|
|
+ JsonParser jsonParser = new JsonParser();
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("tagId", "insert_student");
|
|
|
+
|
|
|
+ for(int i = 1; i < list.size(); i ++){
|
|
|
+ String[] el = list.get(i);
|
|
|
+ if(tableData != null && tableData.containsKey(el[0])){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ paramJson.addProperty("clientId", i);
|
|
|
+ paramJson.addProperty("personId", el[0]);
|
|
|
+ paramJson.addProperty("personName", el[1]);
|
|
|
+ paramJson.addProperty("orgIndexCode", el[2]);
|
|
|
+ paramJson.addProperty("phoneNo", el[6]);
|
|
|
+ paramJson.addProperty("jobNo", el[3]);
|
|
|
+ paramJson.addProperty("birthday", el[5]);
|
|
|
+ paramJson.addProperty("personType", 2);
|
|
|
+
|
|
|
+ int gender;
|
|
|
+ switch (el[4]) {
|
|
|
+ case "SB10001":
|
|
|
+ gender = 1;
|
|
|
+ break;
|
|
|
+ case "SB10002":
|
|
|
+ gender = 2;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ gender = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ paramJson.addProperty("gender", gender);
|
|
|
+
|
|
|
+ clientMap.put(i, el[0]);
|
|
|
+ String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
|
|
|
+ JsonElement parse = jsonParser.parse(result);
|
|
|
+ JsonObject resultJson = parse.getAsJsonObject();
|
|
|
+ if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
|
|
|
+ JsonObject array = resultJson.get("data").getAsJsonObject();
|
|
|
+ idMap.put(el[0], array.get("personId").getAsString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入记录表
|
|
|
+ insertRecord(db, tableName, idMap);
|
|
|
+ return idMap;
|
|
|
+ }
|
|
|
+
|
|
|
public Map<String, String> insertStudent(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,t1.birth_date,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" +
|
|
|
- " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0";
|
|
|
+ " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND t3.class_type IS NOT NULL ";
|
|
|
List<String[]> list = db.query(sql, String[].class);
|
|
|
Map<Integer, String> clientMap = new HashMap<>();
|
|
|
|
|
|
@@ -267,7 +327,7 @@ public class DataUtil {
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
header.put("tagId", "insert_student");
|
|
|
|
|
|
- int maxCount = 1000;
|
|
|
+ int maxCount = 100;
|
|
|
|
|
|
int frequency = list.size() / maxCount;
|
|
|
for(int index = 0; index < frequency; index ++){
|
|
|
@@ -441,7 +501,7 @@ public class DataUtil {
|
|
|
JsonElement parse = jsonParser.parse(result);
|
|
|
|
|
|
JsonObject resultJson = parse.getAsJsonObject();
|
|
|
- if (resultJson.get("code").getAsInt() == 0 && "success".equals(resultJson.get("msg").getAsString())) {
|
|
|
+ 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();
|