Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* bms财务结算系统feign调用接口
|
* bms财务结算系统feign调用接口
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.3:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||||
public interface BmsServiceFeign {
|
public interface BmsServiceFeign {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.4:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||||
public interface OmsServiceFeign {
|
public interface OmsServiceFeign {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.30:8014",configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class)
|
||||||
public interface WlhyServiceFeign {
|
public interface WlhyServiceFeign {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.Map;
|
|||||||
* @description: TODO
|
* @description: TODO
|
||||||
* @date 2024/5/10 8:58
|
* @date 2024/5/10 8:58
|
||||||
**/
|
**/
|
||||||
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.3:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.32:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||||
public interface WmsServiceFeign {
|
public interface WmsServiceFeign {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration;
|
|||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.4:8018", configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.33:8018", configuration = FeignAutoConfiguration.class)
|
||||||
public interface YmsServiceFeign {
|
public interface YmsServiceFeign {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+54
-36
@@ -161,11 +161,22 @@ public class UserShipperApplicationService {
|
|||||||
|
|
||||||
// 先保存前端传递的 organizationId(如果存在)
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
Long frontendOrganizationId = userShipperDO.getOrganizationId();
|
Long frontendOrganizationId = userShipperDO.getOrganizationId();
|
||||||
|
|
||||||
// 获取当前登录用户的组织信息
|
// 获取当前登录用户的组织信息
|
||||||
Long loginUserOrganizationId = userPo.getOrganizationId();
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
Long topOrganizationId = userPo.getTopOrganizationId();
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 如果前端传了 orgCode(组织ID),直接按 org_code 过滤查询委托方,不覆盖组织条件
|
||||||
|
// orgCode 匹配 user_shipper.org_code JSON 数组中的 code 字段,用于精确查询委托方
|
||||||
|
if (StringUtils.isNotBlank(userShipperDO.getOrgCode())) {
|
||||||
|
// 清空 organizationId / topOrganizationId,避免被数据权限覆盖逻辑拦截 orgCode 已授权的委托方
|
||||||
|
userShipperDO.setOrganizationId(null);
|
||||||
|
userShipperDO.setTopOrganizationId(null);
|
||||||
|
log.info("托运人列表查询 - 按 orgCode 查询:orgCode={}", userShipperDO.getOrgCode());
|
||||||
|
List<UserShipperPo> userShipperList = userShipperDomainService.userShipperList(userShipperDO);
|
||||||
|
return processShipperList(userShipperList);
|
||||||
|
}
|
||||||
|
|
||||||
// 数据权限:根据 organizationId 来设置查询权限
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
@@ -184,32 +195,13 @@ public class UserShipperApplicationService {
|
|||||||
log.info("托运人列表查询 - 南光组织查询所有组织:不设置组织过滤条件");
|
log.info("托运人列表查询 - 南光组织查询所有组织:不设置组织过滤条件");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 其他组织:设置 organizationId,只查询当前组织的数据
|
// 其他组织:设置 organizationId 为当前登录组织ID。
|
||||||
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
// 查询条件为:a.organization_id = 本组织 OR b.org_code LIKE 本组织ID
|
||||||
if (frontendOrganizationId != null) {
|
// 即委托方初始绑定本组织、或 org_code 中包含本组织(被授权给本组织)时,均可查到。
|
||||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
// 不设置 topOrganizationId,避免跨顶级组织授权(org_code 已包含本组织)被顶级组织条件拦截。
|
||||||
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
||||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
userShipperDO.setTopOrganizationId(null);
|
||||||
log.warn("托运人列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
log.info("托运人列表查询 - 其他组织按本组织及 org_code 查询:organizationId={}", loginUserOrganizationId);
|
||||||
frontendOrganizationId, loginUserOrganizationId);
|
|
||||||
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
|
||||||
if (frontendOrganizationId.equals(2827L)){
|
|
||||||
userShipperDO.setOrganizationId(null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
|
||||||
userShipperDO.setOrganizationId(frontendOrganizationId);
|
|
||||||
}
|
|
||||||
if (topOrganizationId != null) {
|
|
||||||
userShipperDO.setTopOrganizationId(topOrganizationId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
|
||||||
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
|
||||||
if (topOrganizationId != null) {
|
|
||||||
userShipperDO.setTopOrganizationId(topOrganizationId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("托运人列表查询 - 设置组织ID后,查询参数:organizationId={}, topOrganizationId={}, userId={}",
|
log.info("托运人列表查询 - 设置组织ID后,查询参数:organizationId={}, topOrganizationId={}, userId={}",
|
||||||
@@ -413,10 +405,15 @@ public class UserShipperApplicationService {
|
|||||||
shipperDO.setShipperEnterpriseName(companyName);
|
shipperDO.setShipperEnterpriseName(companyName);
|
||||||
// NC客户编码使用模板中的独立字段,不再复用登录账号
|
// NC客户编码使用模板中的独立字段,不再复用登录账号
|
||||||
shipperDO.setCustomerNcCode(ncCustomerCode);
|
shipperDO.setCustomerNcCode(ncCustomerCode);
|
||||||
// 联系人 -> user表 user_name + user_shipper表 user_name_shipper
|
// 公司名称 -> user表 user_name + user_shipper表 user_name_shipper
|
||||||
shipperDO.setUserName(contactName);
|
shipperDO.setUserName(companyName);
|
||||||
shipperDO.setUserNameShipper(contactName);
|
shipperDO.setUserNameShipper(contactName);
|
||||||
// 联系电话 -> user表 user_phone
|
// 登录账号 -> user表 user_member_code
|
||||||
|
shipperDO.setUserMemberCode(userAccount);
|
||||||
|
// 联系人 -> user表 emergency_contact_name
|
||||||
|
shipperDO.setEmergencyContactName(contactName);
|
||||||
|
// 联系电话 -> user表 emergency_contact_phone
|
||||||
|
shipperDO.setEmergencyContactPhone(contactPhone);
|
||||||
shipperDO.setUserPhone(contactPhone);
|
shipperDO.setUserPhone(contactPhone);
|
||||||
// 地址 -> user表 user_area_name,详细地址 -> user表 user_area_address
|
// 地址 -> user表 user_area_name,详细地址 -> user表 user_area_address
|
||||||
shipperDO.setUserAreaName(address);
|
shipperDO.setUserAreaName(address);
|
||||||
@@ -461,16 +458,30 @@ public class UserShipperApplicationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入时若账号没有任何角色,则补分配企业货主角色
|
* 导入委托方时,确保账号仅绑定企业货主(company)角色。
|
||||||
|
* 注意:authShipper 会把“当前登录管理员的所有角色”都分配给导入用户,
|
||||||
|
* 因此这里必须保证用户最终只绑定 company 角色——若现有角色不是“唯一的 company 角色”,
|
||||||
|
* 一律删除后重新分配,避免残留 ownerCargo 等多条错误角色。
|
||||||
*/
|
*/
|
||||||
private void assignCompanyRoleIfMissing(Long userId, Long organizationId) {
|
private void assignCompanyRoleIfMissing(Long userId, Long organizationId) {
|
||||||
if (userId == null || organizationId == null) {
|
if (userId == null || organizationId == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 查询用户现有角色
|
||||||
List<UserRoleMenuPO> existingRoles = userRoleDomainService.selectRolesByUserId(userId);
|
List<UserRoleMenuPO> existingRoles = userRoleDomainService.selectRolesByUserId(userId);
|
||||||
if (CollUtil.isNotEmpty(existingRoles)) {
|
// 只有恰好绑定了唯一的 company 角色时,才认为正确,无需处理
|
||||||
|
boolean onlyCompany = !CollUtil.isEmpty(existingRoles)
|
||||||
|
&& existingRoles.size() == 1
|
||||||
|
&& RoleEnum.COMPANY.getCode().equals(existingRoles.get(0).getRoleCode());
|
||||||
|
if (onlyCompany) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 否则:删除所有现有角色(ownerCargo、或多个角色),重新分配 company
|
||||||
|
if (CollUtil.isNotEmpty(existingRoles)) {
|
||||||
|
log.info("导入委托方 - 用户{}角色不正确,删除原角色后重新分配company,原角色: {}",
|
||||||
|
userId, existingRoles.stream().map(UserRoleMenuPO::getRoleCode).collect(Collectors.toList()));
|
||||||
|
userRoleDomainService.deleteByUserId(userId);
|
||||||
|
}
|
||||||
// 按 role_code + organization_id 精确匹配角色(selectByOrganizationIdAndRoleCode 的 common_where 不含 roleCode 过滤,不适用)
|
// 按 role_code + organization_id 精确匹配角色(selectByOrganizationIdAndRoleCode 的 common_where 不含 roleCode 过滤,不适用)
|
||||||
RolePO rolePO = roleDomainService.selectByRoleCodeAndOrganizationId(RoleEnum.COMPANY.getCode(), organizationId);
|
RolePO rolePO = roleDomainService.selectByRoleCodeAndOrganizationId(RoleEnum.COMPANY.getCode(), organizationId);
|
||||||
if (rolePO == null) {
|
if (rolePO == null) {
|
||||||
@@ -547,8 +558,15 @@ public class UserShipperApplicationService {
|
|||||||
userDO.setUserId(userId);
|
userDO.setUserId(userId);
|
||||||
if (StringUtils.isNotBlank(userAccount)) {
|
if (StringUtils.isNotBlank(userAccount)) {
|
||||||
userDO.setUserAccount(userAccount);
|
userDO.setUserAccount(userAccount);
|
||||||
|
// 登录账号 -> user表 user_member_code
|
||||||
|
userDO.setUserMemberCode(userAccount);
|
||||||
}
|
}
|
||||||
userDO.setUserName(contactName);
|
// 公司名称 -> user表 user_name
|
||||||
|
userDO.setUserName(companyName);
|
||||||
|
// 联系人 -> user表 emergency_contact_name
|
||||||
|
userDO.setEmergencyContactName(contactName);
|
||||||
|
// 联系电话 -> user表 emergency_contact_phone
|
||||||
|
userDO.setEmergencyContactPhone(contactPhone);
|
||||||
userDO.setUserPhone(contactPhone);
|
userDO.setUserPhone(contactPhone);
|
||||||
userDO.setUserAreaName(address);
|
userDO.setUserAreaName(address);
|
||||||
userDO.setUserAreaAddress(detailedAddress);
|
userDO.setUserAreaAddress(detailedAddress);
|
||||||
@@ -564,8 +582,8 @@ public class UserShipperApplicationService {
|
|||||||
userDO.setUserSalt(salt);
|
userDO.setUserSalt(salt);
|
||||||
}
|
}
|
||||||
userDomainService.updateUser(userDO);
|
userDomainService.updateUser(userDO);
|
||||||
// 如果该账号没有任何角色,补分配企业货主角色,避免登录报“账号未授权角色信息”
|
// 如果该账号没有企业货主(company)角色,补分配当前导入组织下的 company 角色,避免登录报“账号未授权角色信息”
|
||||||
assignCompanyRoleIfMissing(userId, existingShipper.getOrganizationId());
|
assignCompanyRoleIfMissing(userId, currentOrgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 更新 orgCode 中当前组织的 ncCustomer
|
// 3. 更新 orgCode 中当前组织的 ncCustomer
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public class UserShipperDomainService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @DataPermissions(cacheName = "master")
|
// @DataPermissions(cacheName = "master")
|
||||||
public List<UserShipperPo> userShipperList(UserShipperDO userShipperDO) {
|
public List<UserShipperPo> userShipperList(UserShipperDO userShipperDO) {
|
||||||
// 数据权限逻辑已在 UserShipperApplicationService.userShipperList 中处理
|
// 数据权限逻辑已在 UserShipperApplicationService.userShipperList 中处理
|
||||||
// 这里不再重复处理数据权限,直接使用传入的参数进行查询
|
// 这里不再重复处理数据权限,直接使用传入的参数进行查询
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ spring:
|
|||||||
discovery:
|
discovery:
|
||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
# server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
config:
|
config:
|
||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
# server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||||
|
|||||||
@@ -781,7 +781,11 @@
|
|||||||
/*组织ID - 数据隔离:南光组织(organizationId=2827)查询全部,其他组织查询自己组织的数据*/
|
/*组织ID - 数据隔离:南光组织(organizationId=2827)查询全部,其他组织查询自己组织的数据*/
|
||||||
<if test="organizationId !=null">
|
<if test="organizationId !=null">
|
||||||
AND (
|
AND (
|
||||||
u.organization_id = #{organizationId}
|
u.organization_id = #{organizationId}
|
||||||
|
OR b.org_code LIKE concat('%"code":"', #{organizationId}, '"%')
|
||||||
|
OR b.org_code LIKE concat('%code:', #{organizationId}, '%')
|
||||||
|
OR b.org_code LIKE concat('%code: ', #{organizationId}, '%')
|
||||||
|
OR b.org_code LIKE concat('%"code":', #{organizationId}, '%')
|
||||||
)
|
)
|
||||||
AND u.organization_name IS NOT NULL
|
AND u.organization_name IS NOT NULL
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -378,9 +378,23 @@
|
|||||||
and b.parent_shipper_id = #{parentShipperId}
|
and b.parent_shipper_id = #{parentShipperId}
|
||||||
</if>
|
</if>
|
||||||
/*用户组织ID*/
|
/*用户组织ID*/
|
||||||
<if test="organizationId !=null">
|
/*用户组织ID*/
|
||||||
|
<if test="organizationId !=null or (orgCode != null and orgCode != '')">
|
||||||
AND (
|
AND (
|
||||||
|
<if test="organizationId !=null">
|
||||||
a.organization_id = #{organizationId}
|
a.organization_id = #{organizationId}
|
||||||
|
OR b.org_code LIKE concat('%"code":"', #{organizationId}, '"%')
|
||||||
|
OR b.org_code LIKE concat('%code:', #{organizationId}, '%')
|
||||||
|
OR b.org_code LIKE concat('%code: ', #{organizationId}, '%')
|
||||||
|
OR b.org_code LIKE concat('%"code":', #{organizationId}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="orgCode != null and orgCode != ''">
|
||||||
|
<if test="organizationId !=null"> OR </if>
|
||||||
|
b.org_code LIKE concat('%code:', #{orgCode}, '%')
|
||||||
|
OR b.org_code LIKE concat('%code: ', #{orgCode}, '%')
|
||||||
|
OR b.org_code LIKE concat('%"code":', #{orgCode}, '%')
|
||||||
|
OR b.org_code LIKE concat('%"code":"', #{orgCode}, '"%')
|
||||||
|
</if>
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
/*组织名称*/
|
/*组织名称*/
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* 三方服务 Feign
|
* 三方服务 Feign
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.102.192.30:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.102.192.31:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
|
||||||
public interface ThirdPartyServiceFeign {
|
public interface ThirdPartyServiceFeign {
|
||||||
|
|
||||||
//查询当前组织所有三方接口信息
|
//查询当前组织所有三方接口信息
|
||||||
|
|||||||
Reference in New Issue
Block a user