From 216329a3450d7fe44ee8d411f2d873a17cbc5fb3 Mon Sep 17 00:00:00 2001 From: hongqiwei <1143662660@qq.com> Date: Fri, 11 Sep 2026 17:26:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E5=9C=A8=E8=81=8C=E7=8A=B6=E6=80=81=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=80=E4=BC=91=E4=BA=BA=E5=91=98=E5=90=97?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=B8=A4=E4=B8=AA=E5=9C=A8=E8=81=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/v/nutz/sys/models/Sys_user.java | 16 +++++ .../v/nutz/zhgh/data/constant/SourceData.java | 8 +-- .../service/impl/SourceUserServiceImpl.java | 10 ++-- .../views/platform/data/user/SourceUser.html | 60 ++++++++++++++----- 4 files changed, 69 insertions(+), 25 deletions(-) diff --git a/src/main/java/io/v/nutz/sys/models/Sys_user.java b/src/main/java/io/v/nutz/sys/models/Sys_user.java index 9c7ec61..3a473cc 100644 --- a/src/main/java/io/v/nutz/sys/models/Sys_user.java +++ b/src/main/java/io/v/nutz/sys/models/Sys_user.java @@ -366,6 +366,22 @@ public class Sys_user extends BaseModel implements Serializable { @ColDefine(type = ColType.VARCHAR, width = 10) private String userState; + /** + * 数据中心 ZZZTM 原始代码;源数据全量保存,人员更新仅处理代码为 100 的记录。 + */ + @Column + @Comment("源人员状态代码(ZZZTM)") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String zzztm; + + /** + * 数据中心 ZZZTMC 原始名称,与 zzztm 配对保存,不替代现有 userState 字典值。 + */ + @Column + @Comment("源人员状态名称(ZZZTMC)") + @ColDefine(type = ColType.VARCHAR, width = 100) + private String zzztmc; + @Column @Comment("人员类型") @ColDefine(type = ColType.VARCHAR, width = 20) diff --git a/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java b/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java index f28c715..6507079 100644 --- a/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java +++ b/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java @@ -56,6 +56,8 @@ public interface SourceData { put("SFZJH", new String[]{"idcard"}); // 身份证件号 put("ZZMMM", new String[]{"political"}); // 政治面貌码 put("DQZTM", new String[]{"userState", "personalStatus"}); // 在职状态码 + put("ZZZTM", new String[]{"zzztm"}); // 保留源代码,供人员更新阶段筛选 + put("ZZZTMC", new String[]{"zzztmc"}); // 保留源名称,不做字典转换 put("RYFLMC", new String[]{"personType"}); // 人员类型码 put("ZGXLM", new String[]{"education"}); // 最高学历码 put("ZGXWM", new String[]{"academicDegree"}); // 最高学位码 @@ -104,11 +106,7 @@ public interface SourceData { // checkSuccess(map); List data = map.getAsList("data", NutMap.class); for (NutMap row : data) { - // 手动及定时拉取只保留源字段 ZZZTM 为 100 的人员,缺失或其他值均跳过。 - // 分页仍按源接口 totalCount 推进,当前页全部被过滤也必须继续读取后续页。 - if (!"100".equals(row.getString("ZZZTM"))) { - continue; - } + // 源人员全量保存,包括非 100 和状态缺失的记录;筛选统一放在人员更新阶段。 Map entity = new HashMap(500); row.forEach((k, v) -> { diff --git a/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java b/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java index 1ef4dc5..784a27f 100644 --- a/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java +++ b/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java @@ -116,7 +116,7 @@ public class SourceUserServiceImpl extends ViServiceImpl implements /** * 先同步单位并校验人员引用,再按现有配置生成记录和更新人员。 * @param pullTime 已拉取人员数据的批次时间 - * @param sourceType all 全部更新、add 新增人员、part 按组别及过滤字段更新 + * @param sourceType all 全部更新、add 新增人员、part 按组别及过滤字段更新,三种方式均只处理 zzztm=100 * @param columnNames 部分更新时忽略的字段名,可为空 * @param isUpSet 保留现有接口参数,当前方法不使用 * @param partGroupId 更新组别 ID,为空时使用整个批次 @@ -131,19 +131,21 @@ public class SourceUserServiceImpl extends ViServiceImpl implements sysUnitService.syncSourceUnits(); List sources = new ArrayList<>(); Map userPartMap = new HashMap<>(); + // 三种更新方式及定时更新共用筛选;先于分组、单位校验和会员变更,其他源记录仍保留。 + Cnd sourceCnd = Cnd.where("pullTime", "=", pullTime).and("zzztm", "=", "100"); if (Strings.isNotBlank(partGroupId)) { //如果为true,更新组别之外人员 Sql sql = Sqls.create("select u.loginname from user_part up left join `user` u on u.id=up.userId where up.groupId = @groupId").setParam("groupId", partGroupId); List loginNameList = userPatUpService.listMap(sql).stream().map(o -> o.getString("loginname")).collect(Collectors.toList()); if (isInvert) { - sources = query(Cnd.where("pullTime", "=", pullTime).and("loginname", "not in", loginNameList).groupBy("loginname")); + sources = query(sourceCnd.and("loginname", "not in", loginNameList).groupBy("loginname")); userPartMap = sources.stream().collect(Collectors.toMap(Sys_user::getLoginname, Sys_user::getLoginname)); } else { userPartMap = userPatUpService.query(Cnd.where("groupId", "=", partGroupId)).stream().collect(Collectors.toMap(UserPartUp::getLoginname, UserPartUp::getLoginname)); - sources = query(Cnd.where("pullTime", "=", pullTime).and("loginname", "in", loginNameList).groupBy("loginname")); + sources = query(sourceCnd.and("loginname", "in", loginNameList).groupBy("loginname")); } } else { - sources = query(Cnd.where("pullTime", "=", pullTime).groupBy("loginname")); + sources = query(sourceCnd.groupBy("loginname")); } // 查询所有用户,判断是否需要更新 diff --git a/src/main/resources/views/platform/data/user/SourceUser.html b/src/main/resources/views/platform/data/user/SourceUser.html index 849a4bd..167a99b 100644 --- a/src/main/resources/views/platform/data/user/SourceUser.html +++ b/src/main/resources/views/platform/data/user/SourceUser.html @@ -232,13 +232,17 @@ layout("/layouts/platform.html"){ } }) }, - async getLatelyUpdateTimes() { - const resp = await $.get("/platform/data/user/update/latelyUpdateTimes") - if(resp.code===0){ - this.latelyDeleteTimes = resp.data - }else{ - this.$message.warning(resp.msg) - } + getLatelyUpdateTimes() { + // 批次查询失败只提示刷新异常,不改变已经确认的拉取结果。 + return $.get("/platform/data/user/update/latelyUpdateTimes").then((resp) => { + if (resp && resp.code === 0) { + this.latelyDeleteTimes = resp.data + } else { + this.$message.warning((resp && resp.msg) || '拉取批次刷新失败,请刷新页面查看') + } + }, () => { + this.$message.warning('拉取批次刷新失败,请刷新页面查看') + }) }, openDeleteUser() { if (!this.latelyDeleteTimes.length) { @@ -276,20 +280,44 @@ layout("/layouts/platform.html"){ this.selection = val; }, pull(isIncrement) { + // 请求未结束时禁止重复提交,避免同一人员数据被重复拉取成多个批次。 + if (this.pullLoading) { + return + } this.$confirm('确定要从数据中心拉取数据吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' - }).then(async () => { - this.pullLoading = true - const resp = await $.post(loc() + '/pull') - this.pullLoading = false - if(resp.code===0){ - await this.getLatelyUpdateTimes() - this.pageData() - }else{ - this.$message.warning(resp.msg) + }).then(() => { + if (this.pullLoading) { + return } + this.pullLoading = true + // 无请求参数;code=0 表示后端已完成拉取,msg 为业务失败说明。 + // HTTP 异常不能证明后台失败,提示核对批次,不自动重试。 + $.post(loc() + '/pull').then((resp) => { + if (resp && resp.code === 0) { + this.$message.success('人员数据拉取成功') + return true + } + this.$message.warning((resp && resp.msg) || '未收到有效的拉取结果,请刷新核对最新批次,避免重复拉取') + return false + }, () => { + this.$message.warning('未收到拉取完成确认,请刷新核对最新批次,避免重复拉取') + return false + }).always(() => { + this.pullLoading = false + }).done((success) => { + // 先结束拉取 loading,再独立刷新批次和列表,刷新异常不误报拉取失败。 + if (success) { + this.getLatelyUpdateTimes() + this.pageData().fail(() => { + this.$message.warning('人员数据已拉取成功,但列表刷新失败,请刷新页面查看') + }) + } + }) + }, () => { + // 用户取消确认时未提交拉取请求,无需显示请求失败提示。 }) },