This commit is contained in:
wuweihua
2026-11-11 14:50:58 +08:00
2 changed files with 65 additions and 1 deletions
@@ -137,6 +137,7 @@ public class OrgSyncService
// 现有机构:部门名称 -> deptId(重名时优先“威狮国际”直属部门)
List<SysDept> bmsDepts = orgSyncWriter.readSyncDepts();
Map<String, Long> bmsDeptIdByName = new HashMap<String, Long>();
Map<Long, String> bmsDeptNameById = new HashMap<Long, String>();
for (SysDept d : bmsDepts)
{
String name = clean(d.getDeptName());
@@ -144,6 +145,7 @@ public class OrgSyncService
{
continue;
}
bmsDeptNameById.put(d.getDeptId(), name);
Long exist = bmsDeptIdByName.get(name);
if (exist == null
|| (d.getParentId() != null && d.getParentId().longValue() == ROOT_DEPT_ID
@@ -267,6 +269,18 @@ public class OrgSyncService
orgSyncWriter.insertNewUsers(toInsert);
List<Map<String, Object>> createdUsers = new ArrayList<Map<String, Object>>();
for (SysUser user : toInsert)
{
Map<String, Object> createdUser = new LinkedHashMap<String, Object>();
createdUser.put("userName", user.getUserName());
createdUser.put("nickName", user.getNickName());
createdUser.put("deptName", bmsDeptNameById.getOrDefault(user.getDeptId(), ROOT_DEPT_NAME));
createdUser.put("phonenumber", user.getPhonenumber());
createdUser.put("status", user.getStatus());
createdUsers.add(createdUser);
}
long cost = System.currentTimeMillis() - t0;
String summary = String.format(
"TMS 用户同步完成:读取 TMS 员工 %d 人,已存在保持不变 %d 人(工号匹配 %d / 姓名+机构匹配 %d),新增 %d 人(其中机构未匹配挂“%s”%d 人),跳过 %d 条,耗时 %dms。新用户默认密码 123456,未分配角色。",
@@ -283,6 +297,7 @@ public class OrgSyncService
result.put("orgFallbackCount", orgFallback);
result.put("skipCount", skipped);
result.put("costMs", cost);
result.put("createdUsers", createdUsers);
result.put("summary", summary);
return result;
}
+50 -1
View File
@@ -154,6 +154,43 @@
</template>
</el-dialog>
<!-- TMS 用户同步结果:展示本次新增用户及同步统计 -->
<el-dialog title="TMS 用户同步结果" v-model="syncResultVisible" width="980px" append-to-body>
<el-descriptions :column="3" border size="small" class="sync-result-summary">
<el-descriptions-item label="TMS员工数">{{ syncResult.total }}</el-descriptions-item>
<el-descriptions-item label="已存在用户">{{ syncResult.existCount }}</el-descriptions-item>
<el-descriptions-item label="本次新增">{{ syncResult.insertCount }}</el-descriptions-item>
<el-descriptions-item label="跳过记录">{{ syncResult.skipCount }}</el-descriptions-item>
<el-descriptions-item label="部门未匹配">{{ syncResult.orgFallbackCount }}</el-descriptions-item>
<el-descriptions-item label="耗时">{{ syncResult.costMs }} ms</el-descriptions-item>
</el-descriptions>
<el-alert
class="sync-result-tip"
title="下表展示本次新建的用户;已存在和跳过的记录可查看上方统计。"
type="info"
:closable="false"
show-icon
/>
<el-table :data="syncResult.createdUsers" border stripe max-height="480">
<el-table-column prop="userName" label="工号" min-width="140" show-overflow-tooltip />
<el-table-column prop="nickName" label="用户昵称" min-width="140" show-overflow-tooltip />
<el-table-column prop="deptName" label="归属部门" min-width="180" show-overflow-tooltip />
<el-table-column prop="phonenumber" label="手机号码" min-width="130" />
<el-table-column label="状态" width="100" align="center">
<template #default="{ row }">
<el-tag :type="row.status === '0' ? 'success' : 'info'">
{{ row.status === '0' ? '正常' : '停用' }}
</el-tag>
</template>
</el-table-column>
</el-table>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="syncResultVisible = false">关 闭</el-button>
</div>
</template>
</el-dialog>
<!-- 用户详情抽屉 -->
<user-view-drawer ref="userViewRef" />
<!-- 用户导入对话框 -->
@@ -179,6 +216,8 @@ const { sys_normal_disable, sys_user_sex } = useDict("sys_normal_disable", "sys_
const tableRef = ref()
const syncLoading = ref(false)
const syncResultVisible = ref(false)
const syncResult = ref({ total: 0, existCount: 0, insertCount: 0, skipCount: 0, orgFallbackCount: 0, costMs: 0, createdUsers: [] })
const open = ref(false)
const title = ref("")
const deptOptions = ref(undefined)
@@ -276,7 +315,17 @@ function handleSyncFromOracle() {
syncLoading.value = true
return syncUsersFromOracle()
}).then(res => {
proxy.$modal.msgSuccess(res.msg || '同步成功')
const result = res.data || {}
syncResult.value = {
total: result.total || 0,
existCount: result.existCount || 0,
insertCount: result.insertCount || 0,
skipCount: result.skipCount || 0,
orgFallbackCount: result.orgFallbackCount || 0,
costMs: result.costMs || 0,
createdUsers: Array.isArray(result.createdUsers) ? result.createdUsers : []
}
syncResultVisible.value = true
getDeptTree()
tableRef.value.refresh()
}).catch(() => {}).finally(() => {