|
@@ -11,7 +11,6 @@ import org.apache.commons.csv.CSVFormat;
|
|
import org.apache.commons.csv.CSVParser;
|
|
import org.apache.commons.csv.CSVParser;
|
|
import org.apache.commons.csv.CSVRecord;
|
|
import org.apache.commons.csv.CSVRecord;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -20,7 +19,10 @@ import java.io.InputStreamReader;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@@ -69,16 +71,16 @@ public class CheckTask {
|
|
try (CSVParser parser = CSVFormat.DEFAULT.builder().build()
|
|
try (CSVParser parser = CSVFormat.DEFAULT.builder().build()
|
|
.parse(new InputStreamReader(Files.newInputStream(Paths.get(taskConfig.getDistinctFilename())),
|
|
.parse(new InputStreamReader(Files.newInputStream(Paths.get(taskConfig.getDistinctFilename())),
|
|
StandardCharsets.UTF_8))) {
|
|
StandardCharsets.UTF_8))) {
|
|
- Set<String> loginNames = new HashSet<>();
|
|
|
|
|
|
+// Set<String> loginNames = new HashSet<>();
|
|
Map<Object, Map<String, Object>> userMap = getUserMap();
|
|
Map<Object, Map<String, Object>> userMap = getUserMap();
|
|
for (CSVRecord t : parser) {
|
|
for (CSVRecord t : parser) {
|
|
String loginName = t.get(0);
|
|
String loginName = t.get(0);
|
|
String orgName = t.get(2);
|
|
String orgName = t.get(2);
|
|
String cityId = t.get(8);
|
|
String cityId = t.get(8);
|
|
- loginNames.add(loginName);
|
|
|
|
|
|
+// loginNames.add(loginName);
|
|
checkUserInfoChanged(modifiedUsers, userMap, orgName, loginName, cityId);
|
|
checkUserInfoChanged(modifiedUsers, userMap, orgName, loginName, cityId);
|
|
}
|
|
}
|
|
- checkDeletedUser(loginNames);
|
|
|
|
|
|
+// checkDeletedUser(loginNames);
|
|
checkRoleCity();
|
|
checkRoleCity();
|
|
if (!CollectionUtils.isEmpty(modifiedUsers)) {
|
|
if (!CollectionUtils.isEmpty(modifiedUsers)) {
|
|
log.error("信息变化用户: {}", JSON.toJSONString(modifiedUsers));
|
|
log.error("信息变化用户: {}", JSON.toJSONString(modifiedUsers));
|
|
@@ -114,8 +116,10 @@ public class CheckTask {
|
|
String orgName, String loginName, String cityId) {
|
|
String orgName, String loginName, String cityId) {
|
|
// 检查用户信息变化
|
|
// 检查用户信息变化
|
|
Map<String, Object> user = userMap.get(loginName);
|
|
Map<String, Object> user = userMap.get(loginName);
|
|
|
|
+// boolean infoChanged = user != null
|
|
|
|
+// && (!cityId.equals(String.valueOf(user.get("city_id"))) || !orgName.equals(user.get("org")));
|
|
boolean infoChanged = user != null
|
|
boolean infoChanged = user != null
|
|
- && (!cityId.equals(String.valueOf(user.get("city_id"))) || !orgName.equals(user.get("org")));
|
|
|
|
|
|
+ && !cityId.equals(String.valueOf(user.get("city_id")));
|
|
if (infoChanged) {
|
|
if (infoChanged) {
|
|
modifiedUsers.add(user.get("user_id"));
|
|
modifiedUsers.add(user.get("user_id"));
|
|
log.warn("用户 {} 信息变化: {} -> {}, {} -> {}", user.get("user_id"), user.get("city_id"), cityId,
|
|
log.warn("用户 {} 信息变化: {} -> {}, {} -> {}", user.get("user_id"), user.get("city_id"), cityId,
|
|
@@ -141,22 +145,22 @@ public class CheckTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 检查删除用户
|
|
|
|
- *
|
|
|
|
- * @param loginNames 账号列表
|
|
|
|
- */
|
|
|
|
- private void checkDeletedUser(Set<String> loginNames) {
|
|
|
|
- String sql = "select user_id from sqmdb_rpt.acl_user"
|
|
|
|
- + " where deleted = 0 and test_user = 0 and login_name not in (:loginNames)"
|
|
|
|
- + " order by user_id";
|
|
|
|
- Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
- paramMap.put("loginNames", loginNames);
|
|
|
|
- NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
|
|
|
|
- List<Integer> deletedUsers = namedParameterJdbcTemplate.queryForList(sql, paramMap, Integer.class);
|
|
|
|
- if (!CollectionUtils.isEmpty(deletedUsers)) {
|
|
|
|
- log.error("已删除用户: {}", JSON.toJSONString(deletedUsers));
|
|
|
|
- XxlJobHelper.log("已删除用户: {}", JSON.toJSONString(deletedUsers));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// /**
|
|
|
|
+// * 检查删除用户
|
|
|
|
+// *
|
|
|
|
+// * @param loginNames 账号列表
|
|
|
|
+// */
|
|
|
|
+// private void checkDeletedUser(Set<String> loginNames) {
|
|
|
|
+// String sql = "select user_id from sqmdb_rpt.acl_user"
|
|
|
|
+// + " where deleted = 0 and test_user = 0 and login_name not in (:loginNames)"
|
|
|
|
+// + " order by user_id";
|
|
|
|
+// Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
+// paramMap.put("loginNames", loginNames);
|
|
|
|
+// NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
|
|
|
|
+// List<Integer> deletedUsers = namedParameterJdbcTemplate.queryForList(sql, paramMap, Integer.class);
|
|
|
|
+// if (!CollectionUtils.isEmpty(deletedUsers)) {
|
|
|
|
+// log.error("已删除用户: {}", JSON.toJSONString(deletedUsers));
|
|
|
|
+// XxlJobHelper.log("已删除用户: {}", JSON.toJSONString(deletedUsers));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
}
|
|
}
|