From 1cba0d4052cfb831a54b660c8cd98a257dad6cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=BA=86=E6=B3=B0?= <12369755+htcloud1@user.noreply.gitee.com> Date: Tue, 18 Aug 2026 21:09:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(person/import):=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=B2=BE=E7=AE=80=E5=88=B0=204=20=E5=88=97,=20=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E5=85=AC=E5=8F=B8+=E8=A7=92=E8=89=B2=E7=94=B1?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BizPersonImportVO.java: - @Excel 注解砍掉 orgName (所属公司) + role (角色), 字段保留兼容老模板 - 部门/职务 sort 序号重排: 3, 4 - 模板列头从 6 列精简到 4 列: 姓名/手机号/部门/职务 BizPersonController.java doImport: - 删除 orgName 必填校验 + bizOrgMapper 字符串匹配 orgName → orgId 的旧逻辑 - 删除 p.setOrgId(orgId), 让 BizPersonServiceImpl.insert 按 mainUid + unitType 自动反查主账号 biz_org 兜底 (service 内已有 line 56-70 兜底逻辑) - p.setRole(row.getRole()) 改成 unitType 写死: sponsor → 'supervisor' (监察员), executor → 'meetingExecutor' (会议执行) - 死代码清理: 删除 BizOrg + BizOrgMapper import + @Autowired (controller 内不再使用) 行为变化: - 老模板 (6 列) 上传不会报错, 多出的 orgName/role 列值被忽略 (setter 保留) - sponsor/executor 双端受益, 都不再需要 Excel 提供 orgName/role Co-Authored-By: Claude --- .../controller/BizPersonController.java | 25 +++---------------- .../business/domain/BizPersonImportVO.java | 22 ++++++++++------ 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizPersonController.java b/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizPersonController.java index bfb2c4c..d2de34e 100644 --- a/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizPersonController.java +++ b/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/controller/BizPersonController.java @@ -12,10 +12,8 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.business.domain.BizOrg; import com.ruoyi.business.domain.BizPerson; import com.ruoyi.business.domain.BizPersonImportVO; -import com.ruoyi.business.mapper.BizOrgMapper; import com.ruoyi.business.service.IBizPersonService; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.ServiceException; @@ -31,9 +29,6 @@ public class BizPersonController extends BaseController @Autowired private IBizPersonService bizPersonService; - @Autowired - private BizOrgMapper bizOrgMapper; - @Autowired private SysUserMapper sysUserMapper; @@ -192,28 +187,16 @@ public class BizPersonController extends BaseController r.put("name", row.getName()); r.put("phone", row.getPhone()); try { - // 1. orgName → orgId (按 unitType 精确匹配, 查不到就报错) - String orgName = row.getOrgName(); - if (orgName == null || orgName.trim().isEmpty()) { - throw new ServiceException("所属公司不能为空"); - } - BizOrg orgQuery = new BizOrg(); - orgQuery.setOrgName(orgName.trim()); - orgQuery.setOrgType(unitType); - List matched = bizOrgMapper.selectList(orgQuery); - if (matched == null || matched.isEmpty()) { - String label = "sponsor".equals(unitType) ? "支持单位管理" : "服务机构管理"; - throw new ServiceException("找不到所属公司: " + orgName + " (需先在 [" + label + "] 录入 orgType=" + unitType + " 的公司)"); - } - Long orgId = matched.get(0).getOrgId(); + // 1. orgId 由 BizPersonServiceImpl.insert 按 mainUid + unitType 自动反查主账号 biz_org 兜底 (无需 Excel 提供) + // 2. role 跟 unitType 强绑定: sponsor→supervisor, executor→meetingExecutor (无需 Excel 提供) BizPerson p = new BizPerson(); p.setName(row.getName()); p.setPhone(row.getPhone()); - p.setOrgId(orgId); + // p.setOrgId(orgId); ← 不再设置, service 层按 mainUserId 兜底 p.setDepartment(row.getDepartment()); p.setPosition(row.getPosition()); - p.setRole(row.getRole()); + p.setRole("sponsor".equals(unitType) ? "supervisor" : "meetingExecutor"); p.setStatus("0"); // 默认正常 p.setUnitType(unitType); p.setLoginUsername(row.getPhone()); // 用户名 = 手机号 (要求唯一) diff --git a/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizPersonImportVO.java b/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizPersonImportVO.java index d819fb5..e34b5b3 100644 --- a/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizPersonImportVO.java +++ b/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/domain/BizPersonImportVO.java @@ -6,15 +6,21 @@ import com.ruoyi.common.annotation.Excel; * sponsor 端人员批量导入 VO (中文列头, 用 ruoyi ExcelUtil 解析) * *

区别于 BizPerson 实体: 这里只暴露用户能填写的业务字段, 不包含内部 id/审计字段, - * 列头按原型 sponsor-new-person.html: 姓名/手机号/所属公司/部门/职务/角色/状态. + * 列头精简到 4 列: 姓名/手机号/部门/职务. 所属公司 + 角色 由后端兜底: + *

* *

导入后端会按以下规则创建 sys_user 子账号 (parent_user_id=当前登录主账号): *

+ * + *

历史兼容: orgName/role 字段及 setter 保留, 但不再标注 @Excel; 用户上传老模板多列也能解析, 值被忽略. */ public class BizPersonImportVO { @@ -24,16 +30,18 @@ public class BizPersonImportVO @Excel(name = "手机号", sort = 2) private String phone; - @Excel(name = "所属公司", sort = 3) + // 所属公司: 由后端按 mainUserId + unitType 自动反查主账号 biz_org (BizPersonServiceImpl.insert 兜底) + // 保留 setter 兼容老模板, 但不再导出为 Excel 列 private String orgName; - @Excel(name = "部门", sort = 4) + @Excel(name = "部门", sort = 3) private String department; - @Excel(name = "职务", sort = 5) + @Excel(name = "职务", sort = 4) private String position; - @Excel(name = "角色", sort = 6) + // 角色: 跟 unitType 强绑定, sponsor→supervisor / executor→meetingExecutor, 无需用户填 + // 保留 setter 兼容老模板, 但不再导出为 Excel 列 private String role; public String getName() { return name; }