refactor(person/import): 模板精简到 4 列, 所属公司+角色由后端兜底
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 <noreply@anthropic.com>
This commit is contained in:
+4
-21
@@ -12,10 +12,8 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.business.domain.BizOrg;
|
|
||||||
import com.ruoyi.business.domain.BizPerson;
|
import com.ruoyi.business.domain.BizPerson;
|
||||||
import com.ruoyi.business.domain.BizPersonImportVO;
|
import com.ruoyi.business.domain.BizPersonImportVO;
|
||||||
import com.ruoyi.business.mapper.BizOrgMapper;
|
|
||||||
import com.ruoyi.business.service.IBizPersonService;
|
import com.ruoyi.business.service.IBizPersonService;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
@@ -31,9 +29,6 @@ public class BizPersonController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IBizPersonService bizPersonService;
|
private IBizPersonService bizPersonService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BizOrgMapper bizOrgMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper sysUserMapper;
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
@@ -192,28 +187,16 @@ public class BizPersonController extends BaseController
|
|||||||
r.put("name", row.getName());
|
r.put("name", row.getName());
|
||||||
r.put("phone", row.getPhone());
|
r.put("phone", row.getPhone());
|
||||||
try {
|
try {
|
||||||
// 1. orgName → orgId (按 unitType 精确匹配, 查不到就报错)
|
// 1. orgId 由 BizPersonServiceImpl.insert 按 mainUid + unitType 自动反查主账号 biz_org 兜底 (无需 Excel 提供)
|
||||||
String orgName = row.getOrgName();
|
// 2. role 跟 unitType 强绑定: sponsor→supervisor, executor→meetingExecutor (无需 Excel 提供)
|
||||||
if (orgName == null || orgName.trim().isEmpty()) {
|
|
||||||
throw new ServiceException("所属公司不能为空");
|
|
||||||
}
|
|
||||||
BizOrg orgQuery = new BizOrg();
|
|
||||||
orgQuery.setOrgName(orgName.trim());
|
|
||||||
orgQuery.setOrgType(unitType);
|
|
||||||
List<BizOrg> 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();
|
|
||||||
|
|
||||||
BizPerson p = new BizPerson();
|
BizPerson p = new BizPerson();
|
||||||
p.setName(row.getName());
|
p.setName(row.getName());
|
||||||
p.setPhone(row.getPhone());
|
p.setPhone(row.getPhone());
|
||||||
p.setOrgId(orgId);
|
// p.setOrgId(orgId); ← 不再设置, service 层按 mainUserId 兜底
|
||||||
p.setDepartment(row.getDepartment());
|
p.setDepartment(row.getDepartment());
|
||||||
p.setPosition(row.getPosition());
|
p.setPosition(row.getPosition());
|
||||||
p.setRole(row.getRole());
|
p.setRole("sponsor".equals(unitType) ? "supervisor" : "meetingExecutor");
|
||||||
p.setStatus("0"); // 默认正常
|
p.setStatus("0"); // 默认正常
|
||||||
p.setUnitType(unitType);
|
p.setUnitType(unitType);
|
||||||
p.setLoginUsername(row.getPhone()); // 用户名 = 手机号 (要求唯一)
|
p.setLoginUsername(row.getPhone()); // 用户名 = 手机号 (要求唯一)
|
||||||
|
|||||||
+15
-7
@@ -6,15 +6,21 @@ import com.ruoyi.common.annotation.Excel;
|
|||||||
* sponsor 端人员批量导入 VO (中文列头, 用 ruoyi ExcelUtil 解析)
|
* sponsor 端人员批量导入 VO (中文列头, 用 ruoyi ExcelUtil 解析)
|
||||||
*
|
*
|
||||||
* <p>区别于 BizPerson 实体: 这里只暴露用户能填写的业务字段, 不包含内部 id/审计字段,
|
* <p>区别于 BizPerson 实体: 这里只暴露用户能填写的业务字段, 不包含内部 id/审计字段,
|
||||||
* 列头按原型 sponsor-new-person.html: 姓名/手机号/所属公司/部门/职务/角色/状态.
|
* 列头精简到 4 列: 姓名/手机号/部门/职务. 所属公司 + 角色 由后端兜底:
|
||||||
|
* <ul>
|
||||||
|
* <li>所属公司: 由 BizPersonServiceImpl.insert 按 mainUid + unitType 自动反查主账号的 biz_org</li>
|
||||||
|
* <li>角色: sponsor → supervisor (监察员), executor → meetingExecutor (会议执行), 跟 unitType 强绑定</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>导入后端会按以下规则创建 sys_user 子账号 (parent_user_id=当前登录主账号):
|
* <p>导入后端会按以下规则创建 sys_user 子账号 (parent_user_id=当前登录主账号):
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>loginUsername = 手机号 (要求唯一)</li>
|
* <li>loginUsername = 手机号 (要求唯一)</li>
|
||||||
* <li>loginPassword = "123456" (默认密码, 前端 toast 提示用户)</li>
|
* <li>loginPassword = "123456" (默认密码, 前端 toast 提示用户)</li>
|
||||||
* <li>unitType = "sponsor"</li>
|
* <li>unitType = "sponsor" / "executor"</li>
|
||||||
* <li>orgId = 业务层按 orgName 查 biz_org 取 org_id (TODO: SponsorPeople 那边 import 接口需补这步)</li>
|
* <li>orgId = service 层按 mainUserId + unitType 兜底 (无需 Excel 提供)</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>历史兼容: orgName/role 字段及 setter 保留, 但不再标注 @Excel; 用户上传老模板多列也能解析, 值被忽略.
|
||||||
*/
|
*/
|
||||||
public class BizPersonImportVO
|
public class BizPersonImportVO
|
||||||
{
|
{
|
||||||
@@ -24,16 +30,18 @@ public class BizPersonImportVO
|
|||||||
@Excel(name = "手机号", sort = 2)
|
@Excel(name = "手机号", sort = 2)
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
@Excel(name = "所属公司", sort = 3)
|
// 所属公司: 由后端按 mainUserId + unitType 自动反查主账号 biz_org (BizPersonServiceImpl.insert 兜底)
|
||||||
|
// 保留 setter 兼容老模板, 但不再导出为 Excel 列
|
||||||
private String orgName;
|
private String orgName;
|
||||||
|
|
||||||
@Excel(name = "部门", sort = 4)
|
@Excel(name = "部门", sort = 3)
|
||||||
private String department;
|
private String department;
|
||||||
|
|
||||||
@Excel(name = "职务", sort = 5)
|
@Excel(name = "职务", sort = 4)
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
@Excel(name = "角色", sort = 6)
|
// 角色: 跟 unitType 强绑定, sponsor→supervisor / executor→meetingExecutor, 无需用户填
|
||||||
|
// 保留 setter 兼容老模板, 但不再导出为 Excel 列
|
||||||
private String role;
|
private String role;
|
||||||
|
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
|
|||||||
Reference in New Issue
Block a user