TeamImportRunner.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. package tools.team_import;
  2. import java.io.PrintWriter;
  3. import java.lang.reflect.Field;
  4. import java.nio.charset.StandardCharsets;
  5. import java.nio.file.Files;
  6. import java.nio.file.Path;
  7. import java.sql.Connection;
  8. import java.sql.Date;
  9. import java.sql.PreparedStatement;
  10. import java.sql.ResultSet;
  11. import java.sql.Statement;
  12. import java.sql.Timestamp;
  13. import java.time.LocalDate;
  14. import java.util.ArrayList;
  15. import java.util.LinkedHashMap;
  16. import java.util.LinkedHashSet;
  17. import java.util.List;
  18. import java.util.Map;
  19. import java.util.Set;
  20. import ss.db.Db;
  21. /**
  22. * 沙溪团体信息一次性导入工具。
  23. *
  24. * 由临时 JSP 在应用容器内调用,以复用 JNDI 数据源。
  25. */
  26. public class TeamImportRunner {
  27. private static final long TEACHER_ID = 111148350L;
  28. private static final String EFFECTIVE_DATE = "2026-11-01";
  29. private static final String SCHOOL_YEAR = "2026-2027";
  30. private static final Set<String> ALLOWED_SCHEMAS =
  31. Set.of("PMS_TEST", "C##DC");
  32. public static String run(Db db, String groupFile, String memberFile,
  33. String batchId, boolean execute) throws Exception {
  34. return run(db, groupFile, memberFile, batchId, execute, "PMS_TEST");
  35. }
  36. public static String run(Db db, String groupFile, String memberFile,
  37. String batchId, boolean execute,
  38. String expectedSchema) throws Exception {
  39. if (!ALLOWED_SCHEMAS.contains(expectedSchema))
  40. throw new IllegalArgumentException(
  41. "unsupported schema: " + expectedSchema);
  42. List<GroupRow> groups = rdGroups(Path.of(groupFile));
  43. List<MemberRow> members = rdMembers(Path.of(memberFile), groups);
  44. validate(groups, members);
  45. StringBuilder report = new StringBuilder();
  46. report.append("mode=").append(execute ? "EXECUTE" : "DRY_RUN")
  47. .append('\n');
  48. report.append("batch=").append(batchId).append('\n');
  49. report.append("schema=").append(expectedSchema).append('\n');
  50. report.append("TT=").append(groups.size()).append('\n');
  51. report.append("TTCY=").append(members.size()).append('\n');
  52. report.append("TTWCY=").append(members.stream()
  53. .filter(row -> row.memberTable.equals("TTWCY")).count())
  54. .append('\n');
  55. Field connField = Db.class.getDeclaredField("conn");
  56. connField.setAccessible(true);
  57. Connection connection = (Connection) connField.get(db);
  58. String user = scalarString(connection, "select user from dual");
  59. if (!expectedSchema.equals(user)) {
  60. throw new IllegalStateException("refusing import: expected schema "
  61. + expectedSchema + ", current user is " + user);
  62. }
  63. if (!execute) {
  64. report.append("columns=")
  65. .append(importColumnCount(connection)).append('\n');
  66. int existingGroups = 0;
  67. for (GroupRow group : groups) {
  68. if (findGroup(connection, group) > 0)
  69. existingGroups++;
  70. }
  71. report.append("existingGroups=")
  72. .append(existingGroups).append('\n');
  73. if (count(connection,
  74. "select count(*) from user_tables where table_name=?",
  75. "XJB_TT_IMPORT_BATCH") > 0) {
  76. report.append("batchExists=")
  77. .append(count(connection,
  78. "select count(*) from XJB_TT_IMPORT_BATCH "
  79. + "where IMPORT_BATCH_ID=?", batchId))
  80. .append('\n');
  81. } else {
  82. report.append("batchExists=table_missing\n");
  83. }
  84. report.append("DRY_RUN_OK\n");
  85. return report.toString();
  86. }
  87. ensureImportTables(connection);
  88. backupTables(connection, report);
  89. if (count(connection,
  90. "select count(*) from XJB_TT_IMPORT_BATCH where IMPORT_BATCH_ID=?",
  91. batchId) > 0) {
  92. throw new IllegalStateException("import batch already exists: " + batchId);
  93. }
  94. connection.setAutoCommit(false);
  95. try {
  96. insertBatch(connection, batchId, "RUNNING", groups.size(),
  97. members.size(), (int) countRoleRows(members), 4);
  98. ImportCounts counts = new ImportCounts();
  99. Map<GroupKey, Long> groupIds =
  100. importGroups(connection, groups, counts);
  101. importMembers(connection, batchId, members, groupIds, counts);
  102. updateBatch(connection, batchId, "SUCCESS", counts);
  103. connection.commit();
  104. report.append("createdTT=").append(counts.createdGroups).append('\n');
  105. report.append("reusedTT=").append(counts.reusedGroups).append('\n');
  106. report.append("createdTTCY=").append(counts.createdMembers).append('\n');
  107. report.append("reusedTTCY=").append(counts.reusedMembers).append('\n');
  108. report.append("createdTTWCY=").append(counts.createdRoles).append('\n');
  109. report.append("reusedTTWCY=").append(counts.reusedRoles).append('\n');
  110. report.append("IMPORT_OK\n");
  111. return report.toString();
  112. } catch (Exception error) {
  113. connection.rollback();
  114. throw error;
  115. }
  116. }
  117. private static List<GroupRow> rdGroups(Path path) throws Exception {
  118. List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
  119. Map<String, Integer> idx = indexes(lines.get(0));
  120. List<GroupRow> result = new ArrayList<>();
  121. for (int i = 1; i < lines.size(); i++) {
  122. if (lines.get(i).isBlank())
  123. continue;
  124. String[] cols = lines.get(i).split("\t", -1);
  125. result.add(new GroupRow(
  126. cols[idx.get("group_name")],
  127. Integer.parseInt(cols[idx.get("ttlbm")]),
  128. Long.parseLong(cols[idx.get("fzbmid")])));
  129. }
  130. return result;
  131. }
  132. private static List<MemberRow> rdMembers(
  133. Path path, List<GroupRow> groups) throws Exception {
  134. Map<GroupKey, GroupRow> groupMap = new LinkedHashMap<>();
  135. for (GroupRow group : groups)
  136. groupMap.put(group.key(), group);
  137. List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
  138. Map<String, Integer> idx = indexes(lines.get(0));
  139. List<MemberRow> result = new ArrayList<>();
  140. for (int i = 1; i < lines.size(); i++) {
  141. if (lines.get(i).isBlank())
  142. continue;
  143. String[] cols = lines.get(i).split("\t", -1);
  144. GroupKey key = new GroupKey(
  145. cols[idx.get("group_name")],
  146. Integer.parseInt(cols[idx.get("ttlbm")]),
  147. Long.parseLong(cols[idx.get("fzbmid")]));
  148. if (!groupMap.containsKey(key))
  149. throw new IllegalArgumentException(
  150. "group missing in manifest: " + key);
  151. String memberTable = cols[idx.get("member_table")];
  152. int roleCode = 0;
  153. if ("TTWCY".equals(memberTable)) {
  154. roleCode = Integer.parseInt(cols[idx.get("role_code")]);
  155. } else if (!"TTCY".equals(memberTable)) {
  156. throw new IllegalArgumentException(
  157. "invalid member table: " + memberTable);
  158. }
  159. result.add(new MemberRow(
  160. cols[idx.get("source_id")],
  161. key,
  162. Long.parseLong(cols[idx.get("ryid")]),
  163. Long.parseLong(cols[idx.get("bjid")]),
  164. cols[idx.get("source_student_name")],
  165. cols[idx.get("matched_name")],
  166. cols[idx.get("role_name")],
  167. cols[idx.get("role_category")],
  168. roleCode,
  169. memberTable,
  170. cols[idx.get("match_basis")]));
  171. }
  172. return result;
  173. }
  174. private static Map<String, Integer> indexes(String header) {
  175. String[] names = header.split("\t", -1);
  176. Map<String, Integer> result = new LinkedHashMap<>();
  177. for (int i = 0; i < names.length; i++)
  178. result.put(names[i], i);
  179. return result;
  180. }
  181. private static void validate(
  182. List<GroupRow> groups, List<MemberRow> members) {
  183. if (groups.size() != 15)
  184. throw new IllegalArgumentException("expected 15 groups");
  185. if (members.size() != 919)
  186. throw new IllegalArgumentException("expected 919 members");
  187. long roleCount = members.stream()
  188. .filter(row -> row.memberTable.equals("TTWCY")).count();
  189. if (roleCount != 892)
  190. throw new IllegalArgumentException("expected 892 role records");
  191. Set<String> memberKeys = new LinkedHashSet<>();
  192. for (MemberRow row : members) {
  193. String key = row.group + "|" + row.ryid;
  194. if (!memberKeys.add(key))
  195. throw new IllegalArgumentException(
  196. "duplicate group member: " + key);
  197. }
  198. }
  199. private static void ensureImportTables(Connection connection)
  200. throws Exception {
  201. executeIfMissing(connection, "table", "XJB_TT_IMPORT_BATCH",
  202. "create table XJB_TT_IMPORT_BATCH("
  203. + "IMPORT_BATCH_ID varchar2(32) primary key,"
  204. + "STATUS varchar2(16) not null,"
  205. + "TT_COUNT number not null,"
  206. + "TTCY_COUNT number not null,"
  207. + "TTWCY_COUNT number not null,"
  208. + "EXCLUDED_COUNT number not null,"
  209. + "CREATED_AT date not null,"
  210. + "FINISHED_AT date,"
  211. + "MSG varchar2(500))");
  212. executeIfMissing(connection, "table", "XJB_TT_IMPORT_MAP",
  213. "create table XJB_TT_IMPORT_MAP("
  214. + "MAP_ID number primary key,"
  215. + "IMPORT_BATCH_ID varchar2(32) not null,"
  216. + "SOURCE_ID varchar2(32) not null,"
  217. + "GROUP_NAME varchar2(100) not null,"
  218. + "TTID number not null,"
  219. + "TTCYID number not null,"
  220. + "TTWCYID number,"
  221. + "RYID number not null,"
  222. + "STATUS varchar2(16) not null,"
  223. + "CREATED_AT date not null)");
  224. executeIfMissing(connection, "sequence", "XJB_TT_IMPORT_MAP_SEQ",
  225. "create sequence XJB_TT_IMPORT_MAP_SEQ start with 1 increment by 1");
  226. }
  227. private static int importColumnCount(Connection connection)
  228. throws Exception {
  229. return (int) scalarLong(connection,
  230. "select count(*) from user_tab_columns "
  231. + "where (table_name in ('TT','TTCY') "
  232. + "and column_name in ('KSRQ','JSRQ','XNDM')) "
  233. + "or (table_name='TTWCY' "
  234. + "and column_name in ('ZWMC','KSRQ','JSRQ','XNDM'))");
  235. }
  236. private static void backupTables(
  237. Connection connection, StringBuilder report) throws Exception {
  238. for (String table : List.of("TT", "TTCY", "TTWCY")) {
  239. String backup = "BAK_20261109_GROUP_IMPORT_" + table;
  240. if (count(connection,
  241. "select count(*) from user_tables where table_name=?",
  242. backup) == 0) {
  243. try (Statement statement = connection.createStatement()) {
  244. statement.execute("create table " + backup
  245. + " as select * from " + table);
  246. }
  247. }
  248. report.append(backup).append('=')
  249. .append(scalarLong(
  250. connection, "select count(*) from " + backup))
  251. .append('\n');
  252. }
  253. }
  254. private static void executeIfMissing(
  255. Connection connection, String type, String name, String sql)
  256. throws Exception {
  257. long exists;
  258. if ("sequence".equals(type)) {
  259. exists = count(connection,
  260. "select count(*) from user_sequences where sequence_name=?", name);
  261. } else {
  262. exists = count(connection,
  263. "select count(*) from user_tables where table_name=?", name);
  264. }
  265. if (exists == 0) {
  266. try (Statement statement = connection.createStatement()) {
  267. statement.execute(sql);
  268. }
  269. }
  270. }
  271. private static void insertBatch(
  272. Connection connection, String batchId, String status,
  273. int ttCount, int ttcyCount, int ttwcyCount, int excludedCount)
  274. throws Exception {
  275. try (PreparedStatement statement = connection.prepareStatement(
  276. "insert into XJB_TT_IMPORT_BATCH("
  277. + "IMPORT_BATCH_ID,STATUS,TT_COUNT,TTCY_COUNT,"
  278. + "TTWCY_COUNT,EXCLUDED_COUNT,CREATED_AT)"
  279. + " values(?,?,?,?,?,?,?)")) {
  280. statement.setString(1, batchId);
  281. statement.setString(2, status);
  282. statement.setInt(3, ttCount);
  283. statement.setInt(4, ttcyCount);
  284. statement.setInt(5, ttwcyCount);
  285. statement.setInt(6, excludedCount);
  286. statement.setTimestamp(7, new Timestamp(System.currentTimeMillis()));
  287. statement.executeUpdate();
  288. }
  289. }
  290. private static void updateBatch(
  291. Connection connection, String batchId, String status,
  292. ImportCounts counts) throws Exception {
  293. try (PreparedStatement statement = connection.prepareStatement(
  294. "update XJB_TT_IMPORT_BATCH set STATUS=?,FINISHED_AT=?,MSG=?"
  295. + " where IMPORT_BATCH_ID=?")) {
  296. statement.setString(1, status);
  297. statement.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
  298. statement.setString(3,
  299. "createdTT=" + counts.createdGroups
  300. + ",reusedTT=" + counts.reusedGroups
  301. + ",createdTTCY=" + counts.createdMembers
  302. + ",reusedTTCY=" + counts.reusedMembers
  303. + ",createdTTWCY=" + counts.createdRoles
  304. + ",reusedTTWCY=" + counts.reusedRoles);
  305. statement.setString(4, batchId);
  306. statement.executeUpdate();
  307. }
  308. }
  309. private static Map<GroupKey, Long> importGroups(
  310. Connection connection, List<GroupRow> groups,
  311. ImportCounts counts) throws Exception {
  312. Map<GroupKey, Long> result = new LinkedHashMap<>();
  313. for (GroupRow group : groups) {
  314. long id = findGroup(connection, group);
  315. if (id == 0) {
  316. try (PreparedStatement statement = connection.prepareStatement(
  317. "insert into TT(MC,TTLBM,FZBMID,FZRYID,KSRQ,XNDM,"
  318. + "JLZTM,CJRYID,GLRYID,GLBMID,MS)"
  319. + " values(?,?,?,?,?,?,?,?,?,?,?)")) {
  320. statement.setString(1, group.name);
  321. statement.setInt(2, group.ttlbm);
  322. statement.setLong(3, group.fzbmid);
  323. statement.setLong(4, TEACHER_ID);
  324. statement.setDate(5, Date.valueOf(EFFECTIVE_DATE));
  325. statement.setString(6, SCHOOL_YEAR);
  326. statement.setInt(7, 51);
  327. statement.setLong(8, TEACHER_ID);
  328. statement.setLong(9, TEACHER_ID);
  329. statement.setLong(10, group.fzbmid);
  330. statement.setString(11, "团体信息导入");
  331. statement.executeUpdate();
  332. }
  333. id = findGroup(connection, group);
  334. counts.createdGroups++;
  335. } else {
  336. counts.reusedGroups++;
  337. }
  338. if (id == 0)
  339. throw new IllegalStateException("TT insert failed: " + group);
  340. result.put(group.key(), id);
  341. }
  342. return result;
  343. }
  344. private static long findGroup(Connection connection, GroupRow group)
  345. throws Exception {
  346. try (PreparedStatement statement = connection.prepareStatement(
  347. "select TTID from TT where MC=? and TTLBM=? and FZBMID=?"
  348. + " order by TTID")) {
  349. statement.setString(1, group.name);
  350. statement.setInt(2, group.ttlbm);
  351. statement.setLong(3, group.fzbmid);
  352. try (ResultSet result = statement.executeQuery()) {
  353. if (!result.next())
  354. return 0L;
  355. long id = result.getLong(1);
  356. if (result.next())
  357. throw new IllegalStateException(
  358. "multiple TT rows for " + group);
  359. return id;
  360. }
  361. }
  362. }
  363. private static void importMembers(
  364. Connection connection, String batchId, List<MemberRow> members,
  365. Map<GroupKey, Long> groupIds, ImportCounts counts) throws Exception {
  366. for (MemberRow row : members) {
  367. long ttid = groupIds.get(row.group);
  368. long ttcyid = findTtcy(connection, ttid, row.ryid);
  369. if (ttcyid == 0) {
  370. try (PreparedStatement statement = connection.prepareStatement(
  371. "insert into TTCY(TTID,RYID,KSRQ,XNDM,JLZTM,"
  372. + "CJRYID,GLRYID,GLBMID)"
  373. + " values(?,?,?,?,?,?,?,?)")) {
  374. statement.setLong(1, ttid);
  375. statement.setLong(2, row.ryid);
  376. statement.setDate(3, Date.valueOf(EFFECTIVE_DATE));
  377. statement.setString(4, SCHOOL_YEAR);
  378. statement.setInt(5, 51);
  379. statement.setLong(6, TEACHER_ID);
  380. statement.setLong(7, TEACHER_ID);
  381. statement.setLong(8, row.group.fzbmid);
  382. statement.executeUpdate();
  383. }
  384. ttcyid = findTtcy(connection, ttid, row.ryid);
  385. counts.createdMembers++;
  386. } else {
  387. counts.reusedMembers++;
  388. }
  389. if (ttcyid == 0)
  390. throw new IllegalStateException("TTCY insert failed: " + row.sourceId);
  391. Long ttwcyid = null;
  392. if ("TTWCY".equals(row.memberTable)) {
  393. long roleId = findTtwcy(
  394. connection, ttid, row.ryid, row.roleCode);
  395. if (roleId == 0) {
  396. try (PreparedStatement statement = connection.prepareStatement(
  397. "insert into TTWCY(TTID,RYID,TTWCYLBM,ZWMC,"
  398. + "KSRQ,XNDM,JLZTM,CJRYID,GLRYID,GLBMID)"
  399. + " values(?,?,?,?,?,?,?,?,?,?)")) {
  400. statement.setLong(1, ttid);
  401. statement.setLong(2, row.ryid);
  402. statement.setInt(3, row.roleCode);
  403. statement.setString(4, row.roleName);
  404. statement.setDate(5, Date.valueOf(EFFECTIVE_DATE));
  405. statement.setString(6, SCHOOL_YEAR);
  406. statement.setInt(7, 51);
  407. statement.setLong(8, TEACHER_ID);
  408. statement.setLong(9, TEACHER_ID);
  409. statement.setLong(10, row.group.fzbmid);
  410. statement.executeUpdate();
  411. }
  412. roleId = findTtwcy(
  413. connection, ttid, row.ryid, row.roleCode);
  414. counts.createdRoles++;
  415. } else {
  416. counts.reusedRoles++;
  417. }
  418. if (roleId == 0)
  419. throw new IllegalStateException(
  420. "TTWCY insert failed: " + row.sourceId);
  421. ttwcyid = roleId;
  422. }
  423. try (PreparedStatement statement = connection.prepareStatement(
  424. "insert into XJB_TT_IMPORT_MAP("
  425. + "MAP_ID,IMPORT_BATCH_ID,SOURCE_ID,GROUP_NAME,"
  426. + "TTID,TTCYID,TTWCYID,RYID,STATUS,CREATED_AT)"
  427. + " values(XJB_TT_IMPORT_MAP_SEQ.nextval,?,?,?,?,?,?,?,?,?)")) {
  428. statement.setString(1, batchId);
  429. statement.setString(2, row.sourceId);
  430. statement.setString(3, row.group.name);
  431. statement.setLong(4, ttid);
  432. statement.setLong(5, ttcyid);
  433. if (ttwcyid == null)
  434. statement.setNull(6, java.sql.Types.NUMERIC);
  435. else
  436. statement.setLong(6, ttwcyid);
  437. statement.setLong(7, row.ryid);
  438. statement.setString(8,
  439. ttwcyid == null ? "TTCY_ONLY" : "TTCY_TTWCY");
  440. statement.setTimestamp(9,
  441. new Timestamp(System.currentTimeMillis()));
  442. statement.executeUpdate();
  443. }
  444. }
  445. }
  446. private static long findTtcy(
  447. Connection connection, long ttid, long ryid) throws Exception {
  448. try (PreparedStatement statement = connection.prepareStatement(
  449. "select TTCYID from TTCY where TTID=? and RYID=? and JLZTM=51")) {
  450. statement.setLong(1, ttid);
  451. statement.setLong(2, ryid);
  452. try (ResultSet result = statement.executeQuery()) {
  453. return result.next() ? result.getLong(1) : 0L;
  454. }
  455. }
  456. }
  457. private static long findTtwcy(
  458. Connection connection, long ttid, long ryid, int roleCode)
  459. throws Exception {
  460. try (PreparedStatement statement = connection.prepareStatement(
  461. "select TTWCYID from TTWCY where TTID=? and RYID=?"
  462. + " and TTWCYLBM=? and JLZTM=51")) {
  463. statement.setLong(1, ttid);
  464. statement.setLong(2, ryid);
  465. statement.setInt(3, roleCode);
  466. try (ResultSet result = statement.executeQuery()) {
  467. return result.next() ? result.getLong(1) : 0L;
  468. }
  469. }
  470. }
  471. private static long countRoleRows(List<MemberRow> members) {
  472. return members.stream()
  473. .filter(row -> "TTWCY".equals(row.memberTable)).count();
  474. }
  475. private static long count(
  476. Connection connection, String sql, String value) throws Exception {
  477. try (PreparedStatement statement = connection.prepareStatement(sql)) {
  478. statement.setString(1, value);
  479. try (ResultSet result = statement.executeQuery()) {
  480. result.next();
  481. return result.getLong(1);
  482. }
  483. }
  484. }
  485. private static long scalarLong(Connection connection, String sql)
  486. throws Exception {
  487. try (Statement statement = connection.createStatement();
  488. ResultSet result = statement.executeQuery(sql)) {
  489. result.next();
  490. return result.getLong(1);
  491. }
  492. }
  493. private static String scalarString(Connection connection, String sql)
  494. throws Exception {
  495. try (Statement statement = connection.createStatement();
  496. ResultSet result = statement.executeQuery(sql)) {
  497. result.next();
  498. return result.getString(1);
  499. }
  500. }
  501. private static final class GroupKey {
  502. final String name;
  503. final int ttlbm;
  504. final long fzbmid;
  505. GroupKey(String name, int ttlbm, long fzbmid) {
  506. this.name = name;
  507. this.ttlbm = ttlbm;
  508. this.fzbmid = fzbmid;
  509. }
  510. @Override
  511. public boolean equals(Object other) {
  512. if (!(other instanceof GroupKey))
  513. return false;
  514. GroupKey key = (GroupKey) other;
  515. return name.equals(key.name)
  516. && ttlbm == key.ttlbm && fzbmid == key.fzbmid;
  517. }
  518. @Override
  519. public int hashCode() {
  520. return java.util.Objects.hash(name, ttlbm, fzbmid);
  521. }
  522. @Override
  523. public String toString() {
  524. return name + "/" + ttlbm + "/" + fzbmid;
  525. }
  526. }
  527. private static final class GroupRow {
  528. final String name;
  529. final int ttlbm;
  530. final long fzbmid;
  531. GroupRow(String name, int ttlbm, long fzbmid) {
  532. this.name = name;
  533. this.ttlbm = ttlbm;
  534. this.fzbmid = fzbmid;
  535. }
  536. GroupKey key() {
  537. return new GroupKey(name, ttlbm, fzbmid);
  538. }
  539. }
  540. private static final class MemberRow {
  541. final String sourceId;
  542. final GroupKey group;
  543. final long ryid;
  544. final long bjid;
  545. final String sourceName;
  546. final String matchedName;
  547. final String roleName;
  548. final String roleCategory;
  549. final int roleCode;
  550. final String memberTable;
  551. final String matchBasis;
  552. MemberRow(String sourceId, GroupKey group, long ryid, long bjid,
  553. String sourceName, String matchedName, String roleName,
  554. String roleCategory, int roleCode, String memberTable,
  555. String matchBasis) {
  556. this.sourceId = sourceId;
  557. this.group = group;
  558. this.ryid = ryid;
  559. this.bjid = bjid;
  560. this.sourceName = sourceName;
  561. this.matchedName = matchedName;
  562. this.roleName = roleName;
  563. this.roleCategory = roleCategory;
  564. this.roleCode = roleCode;
  565. this.memberTable = memberTable;
  566. this.matchBasis = matchBasis;
  567. }
  568. }
  569. private static final class ImportCounts {
  570. int createdGroups;
  571. int reusedGroups;
  572. int createdMembers;
  573. int reusedMembers;
  574. int createdRoles;
  575. int reusedRoles;
  576. }
  577. }