✨ 放开组织类型层级约束,并修复调度数量单位回填

组织树不再按类型约束上下级;计量维度扩展整车/里程/吨·公里;运单从货物明细补齐数量单位,用户查询支持模糊匹配。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-04 20:26:16 +08:00
parent a5e89aa6dc
commit 683351d764
4 changed files with 77 additions and 28 deletions
@@ -44,13 +44,16 @@
and bu.tenant_id = #{user.tenantId}
</if>
<if test="user.account!=null and user.account != ''">
and bu.account = #{user.account}
and bu.account like concat(concat('%', #{user.account}), '%')
</if>
<if test="user.realName!=null and user.realName != ''">
and bu.real_name = #{user.realName}
and bu.real_name like concat(concat('%', #{user.realName}), '%')
</if>
<if test="user.phone!=null and user.phone != ''">
and bu.phone = #{user.phone}
and (
bu.phone like concat(concat('%', #{user.phone}), '%')
or bu.account like concat(concat('%', #{user.phone}), '%')
)
</if>
<if test="user.userType!=null and user.userType != ''">
and bu.user_type = #{user.userType}
@@ -437,7 +437,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
if (Func.isEmpty(dept.getTenantId())) {
throw new ServiceException("租户ID不能为空");
}
validateDeptCategory(dept, parent);
validateDeptCategory(dept);
validateDeptCode(dept, parent);
return saveOrUpdate(dept);
}
@@ -619,27 +619,8 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
return "Basic " + value;
}
private void validateDeptCategory(Dept dept, Dept parent) {
// 顶级组织不要求选择上级组织
if (parent == null) {
if (Integer.valueOf(6).equals(dept.getDeptCategory()) && Func.isEmpty(dept.getCarrierCustomerId())) {
throw new ServiceException("请选择承运商");
}
return;
}
List<Integer> allowedCategories;
if (BladeConstant.TOP_PARENT_ID.equals(parent.getParentId())) {
allowedCategories = "外部组织".equals(parent.getDeptName()) ? List.of(6) : List.of(1);
} else if (Integer.valueOf(1).equals(parent.getDeptCategory())) {
allowedCategories = List.of(2, 3);
} else if (List.of(2, 3).contains(parent.getDeptCategory())) {
allowedCategories = List.of(4, 5, 6);
} else {
throw new ServiceException("上级组织层级不支持新增下级组织");
}
if (!allowedCategories.contains(dept.getDeptCategory())) {
throw new ServiceException("组织类型不符合上级组织层级规则");
}
private void validateDeptCategory(Dept dept) {
// 组织树层级仅由 parentId / ancestors 决定,组织类型不再做上下级约束
if (Integer.valueOf(6).equals(dept.getDeptCategory()) && Func.isEmpty(dept.getCarrierCustomerId())) {
throw new ServiceException("请选择承运商");
}
@@ -50,7 +50,7 @@ public class MeasurementUnitServiceImpl extends BaseServiceImpl<MeasurementUnitM
private static final int UNIT_NAME_MAX_LENGTH = 50;
private static final int DIMENSION_MAX_LENGTH = 20;
private static final int REMARK_MAX_LENGTH = 200;
private static final Set<String> DIMENSIONS = Set.of("重量", "体积", "数量");
private static final Set<String> DIMENSIONS = Set.of("重量", "体积", "数量", "整车", "里程", "吨·公里");
@Override
public IPage<MeasurementUnitVO> selectMeasurementUnitPage(IPage<MeasurementUnitVO> page,