Merge branch 'refs/heads/dev_qinhongzhan' into dev
# Conflicts: # mhd-auth/src/main/resources/bootstrap.yml # mhd-gateway/src/main/resources/bootstrap.yml # mhd-modules/mhd-system/src/main/resources/bootstrap.yml # mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/entity/UserShipperEntity.java # mhd-user-center/src/main/resources/bootstrap.yml # mhd_finance/src/main/java/com/linke/finance/application/server/reconciliation/ReconciliationApplicationService.java # mhd_transport/src/main/java/com/linke/transport/application/service/warehouse/material/command/CreateMaterialCommand.java
This commit is contained in:
@@ -14,7 +14,7 @@ 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.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
@@ -22,7 +22,7 @@ spring:
|
|||||||
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.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
|
|||||||
+1
-1
@@ -524,7 +524,7 @@ public class TmsOrder implements Serializable {
|
|||||||
private String payer;
|
private String payer;
|
||||||
|
|
||||||
@ApiModelProperty("客户编码nc")
|
@ApiModelProperty("客户编码nc")
|
||||||
private String customsCodeNc;
|
private String customerCodeNc;
|
||||||
|
|
||||||
@ApiModelProperty("制单人编码nc")
|
@ApiModelProperty("制单人编码nc")
|
||||||
private String makerCodeNc;
|
private String makerCodeNc;
|
||||||
|
|||||||
+2
@@ -99,6 +99,8 @@ public class Verification extends BaseVOEntity implements Serializable,Cloneable
|
|||||||
private Long topOrganizationId;
|
private Long topOrganizationId;
|
||||||
@ApiModelProperty("组织表ID")
|
@ApiModelProperty("组织表ID")
|
||||||
private Long organizationId;
|
private Long organizationId;
|
||||||
|
@ApiModelProperty("组织名称")
|
||||||
|
private String organizationName;
|
||||||
// @ApiModelProperty("是否月结:1-是,2-否")
|
// @ApiModelProperty("是否月结:1-是,2-否")
|
||||||
// private Integer receivableType;
|
// private Integer receivableType;
|
||||||
@ApiModelProperty("部门id")
|
@ApiModelProperty("部门id")
|
||||||
|
|||||||
+3
@@ -56,4 +56,7 @@ public class AddressBookPo extends BaseVOEntity implements Serializable
|
|||||||
private String synthesize;
|
private String synthesize;
|
||||||
@ApiModelProperty(name = "单位名称")
|
@ApiModelProperty(name = "单位名称")
|
||||||
private String unitName;
|
private String unitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织ID(用于数据权限过滤,内部使用)", hidden = true)
|
||||||
|
private Long organizationId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ public class RolePO extends BaseVOEntity implements Serializable {
|
|||||||
private String roleTypeName = "";
|
private String roleTypeName = "";
|
||||||
@ApiModelProperty(name = "组织表ID")
|
@ApiModelProperty(name = "组织表ID")
|
||||||
private Long organizationId = 0L;
|
private Long organizationId = 0L;
|
||||||
|
@ApiModelProperty(name = "组织名称")
|
||||||
|
private String organizationName = "";
|
||||||
|
@ApiModelProperty(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId = 0L;
|
||||||
@ApiModelProperty(name = "职务/角色权限字符,控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)")
|
@ApiModelProperty(name = "职务/角色权限字符,控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)")
|
||||||
private String roleCode = "";
|
private String roleCode = "";
|
||||||
@ApiModelProperty(name = "职务/角色名称")
|
@ApiModelProperty(name = "职务/角色名称")
|
||||||
|
|||||||
+2
@@ -28,6 +28,8 @@ public class UserDriverListPo {
|
|||||||
private String driverEnterpriseName="";
|
private String driverEnterpriseName="";
|
||||||
@ApiModelProperty(name = "登录账号(2-20位)")
|
@ApiModelProperty(name = "登录账号(2-20位)")
|
||||||
private String userAccount = "";
|
private String userAccount = "";
|
||||||
|
@ApiModelProperty(name = "组织表ID")
|
||||||
|
private Long organizationId;
|
||||||
@ApiModelProperty(name = "组织名称")
|
@ApiModelProperty(name = "组织名称")
|
||||||
private String organizationName = "";
|
private String organizationName = "";
|
||||||
@ApiModelProperty(name = "身份证号")
|
@ApiModelProperty(name = "身份证号")
|
||||||
|
|||||||
+2
@@ -99,6 +99,8 @@ public class VerificationPo extends BaseVOEntity implements Serializable
|
|||||||
private Long topOrganizationId;
|
private Long topOrganizationId;
|
||||||
@ApiModelProperty("组织表ID")
|
@ApiModelProperty("组织表ID")
|
||||||
private Long organizationId;
|
private Long organizationId;
|
||||||
|
@ApiModelProperty("组织名称")
|
||||||
|
private String organizationName;
|
||||||
// @ApiModelProperty("是否月结:1-是,2-否")
|
// @ApiModelProperty("是否月结:1-是,2-否")
|
||||||
// private Integer receivableType;
|
// private Integer receivableType;
|
||||||
@ApiModelProperty("部门id")
|
@ApiModelProperty("部门id")
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ public class MinIoUploadService {
|
|||||||
private static String host="http://10.102.192.5:6000";
|
private static String host="http://10.102.192.5:6000";
|
||||||
private static String accessKey="minioadmin";
|
private static String accessKey="minioadmin";
|
||||||
private static String secretKey="gmminioadmin";
|
private static String secretKey="gmminioadmin";
|
||||||
|
/**
|
||||||
|
* minio 工具客户端
|
||||||
|
*/
|
||||||
|
private static MinioClient minioClient1 = null;
|
||||||
|
|
||||||
|
private static String FILE_URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传到minio
|
* 上传到minio
|
||||||
|
|||||||
@@ -15,22 +15,21 @@ spring:
|
|||||||
discovery:
|
discovery:
|
||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
server-addr: 10.102.192.5:6848
|
# server-addr: 10.102.192.5:6848
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
# server-addr: mhd-nacos:8848
|
server-addr: 10.102.192.5: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: mhd-nacos:8848
|
# server-addr: 10.102.192.5:6848
|
||||||
|
# server-addr: 10.33.0.129:6010
|
||||||
|
#线上正式环境
|
||||||
server-addr: 10.102.192.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
# server-addr: 10.33.0.129:6010
|
|
||||||
#线上正式环境
|
|
||||||
# server-addr: 10.102.192.105:6848
|
|
||||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||||
file-extension: yml #默认properties
|
file-extension: yml #默认properties
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|||||||
+56
-1
@@ -69,9 +69,37 @@ public class AddressBookApplicationService
|
|||||||
// 获取登录人id
|
// 获取登录人id
|
||||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||||
addressBookPo.setUserId(userId);
|
addressBookPo.setUserId(userId);
|
||||||
|
|
||||||
|
// 添加组织数据权限过滤
|
||||||
|
applyOrganizationDataPermissionForAddressBook(addressBookPo);
|
||||||
|
|
||||||
return addressBookDomainService.selectAddressBookList(addressBookPo);
|
return addressBookDomainService.selectAddressBookList(addressBookPo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤(地址簿)
|
||||||
|
* 通过用户表关联来过滤组织数据
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermissionForAddressBook(AddressBookPo addressBookPo) {
|
||||||
|
try {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可以查询全部组织数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织:需要通过用户表关联来过滤,只查询同一组织下用户创建的地址簿
|
||||||
|
// 由于AddressBook表只有userId字段,需要在XML中通过用户表关联来过滤
|
||||||
|
addressBookPo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
// 如果是2827组织,不设置organizationId,可以查询全部
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 如果获取登录用户信息失败,不添加过滤条件,避免影响正常查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增地址簿
|
* 新增地址簿
|
||||||
*
|
*
|
||||||
@@ -156,12 +184,39 @@ public class AddressBookApplicationService
|
|||||||
*/
|
*/
|
||||||
public List<CommonRoutePo> selectCommonRouteList(CommonRouteDo commonRouteDo){
|
public List<CommonRoutePo> selectCommonRouteList(CommonRouteDo commonRouteDo){
|
||||||
// 获取登录人id
|
// 获取登录人id
|
||||||
// Long userId = SecurityUtils.getUserId()==0 ? 4L:SecurityUtils.getLoginUser().getUserid();
|
|
||||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||||
commonRouteDo.setCreateBy(userId);
|
commonRouteDo.setCreateBy(userId);
|
||||||
|
|
||||||
|
// 添加组织数据权限过滤
|
||||||
|
applyOrganizationDataPermissionForCommonRoute(commonRouteDo);
|
||||||
|
|
||||||
return commonRouteDomainService.selectCommonRouteList(commonRouteDo);
|
return commonRouteDomainService.selectCommonRouteList(commonRouteDo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤(常用路线)
|
||||||
|
* 通过用户表关联来过滤组织数据
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermissionForCommonRoute(CommonRouteDo commonRouteDo) {
|
||||||
|
try {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可以查询全部组织数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织:需要通过用户表关联来过滤,只查询同一组织下用户创建的常用路线
|
||||||
|
// 由于CommonRoute表只有userId字段,需要在XML中通过用户表关联来过滤
|
||||||
|
commonRouteDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
// 如果是2827组织,不设置organizationId,可以查询全部
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 如果获取登录用户信息失败,不添加过滤条件,避免影响正常查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增常用路线
|
* 新增常用路线
|
||||||
*
|
*
|
||||||
|
|||||||
+30
-3
@@ -38,10 +38,30 @@ public class ContainerApplicationService {
|
|||||||
|
|
||||||
public List<ContainerPO> queryList(ContainerDO containerDO) {
|
public List<ContainerPO> queryList(ContainerDO containerDO) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser != null){
|
if (loginUser != null && loginUser.getUserPo() != null){
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
if (topOrganizationId != null && topOrganizationId != 1){
|
|
||||||
containerDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (containerDO.getOrganizationId() == null) {
|
||||||
|
containerDO.setOrganizationId(null);
|
||||||
|
containerDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
if (topOrganizationId != null && topOrganizationId != 1){
|
||||||
|
containerDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
// 如果前端传递了organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (containerDO.getOrganizationId() != null && !containerDO.getOrganizationId().equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
containerDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return containerDomainService.queryList(containerDO);
|
return containerDomainService.queryList(containerDO);
|
||||||
@@ -52,6 +72,13 @@ public class ContainerApplicationService {
|
|||||||
* 新增容器管理
|
* 新增容器管理
|
||||||
*/
|
*/
|
||||||
public Boolean insert(ContainerDO containerDO) {
|
public Boolean insert(ContainerDO containerDO) {
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
containerDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
containerDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||||
|
containerDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
}
|
||||||
//翻译库区类型
|
//翻译库区类型
|
||||||
setDataDict(containerDO);
|
setDataDict(containerDO);
|
||||||
return containerDomainService.insert(containerDO);
|
return containerDomainService.insert(containerDO);
|
||||||
|
|||||||
+131
-11
@@ -22,6 +22,7 @@ import com.mhd.common.core.web.domain.AjaxResult;
|
|||||||
import com.mhd.common.security.utils.SecurityUtils;
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
import com.mhd.system.api.SystemServiceFeign;
|
import com.mhd.system.api.SystemServiceFeign;
|
||||||
import com.mhd.system.api.model.LoginUser;
|
import com.mhd.system.api.model.LoginUser;
|
||||||
|
import com.mhd.common.core.domain.po.UserPo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -50,29 +51,117 @@ public class ExpenseAccountApplicationService {
|
|||||||
/**
|
/**
|
||||||
* 分页查询费用科目列表
|
* 分页查询费用科目列表
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public List<ExpenseAccountPO> queryList(ExpenseAccountDO expenseAccountDO) {
|
public List<ExpenseAccountPO> queryList(ExpenseAccountDO expenseAccountDO) {
|
||||||
setTopOrganizationIdLogin(expenseAccountDO);
|
try {
|
||||||
return expenseAccountDomainService.queryList(expenseAccountDO);
|
log.info("开始查询费用科目列表,参数:organizationId={}, topOrganizationId={}, expenseAccountDO={}",
|
||||||
|
expenseAccountDO.getOrganizationId(), expenseAccountDO.getTopOrganizationId(), expenseAccountDO);
|
||||||
|
setDataPermission(expenseAccountDO);
|
||||||
|
|
||||||
|
// 处理 createByName 和 updateByName 字段:
|
||||||
|
// 问题:ExpenseAccountAssembler 在查询场景下会自动设置 createByName 和 updateByName 为当前登录用户名
|
||||||
|
// 这会导致 SQL 中添加 create_by_name LIKE '%nanguang%' 和 update_by_name LIKE '%nanguang%' 条件
|
||||||
|
// 解决方案:
|
||||||
|
// 1. 如果查询所有组织(organizationId 和 topOrganizationId 都为 null),清空这些字段
|
||||||
|
// 2. 如果查询指定组织(organizationId 不为 null),且是南光组织查询,如果 createByName 或 updateByName 等于当前登录用户名,清空它们
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
String currentUserName = loginUser.getUsername();
|
||||||
|
|
||||||
|
if (expenseAccountDO.getOrganizationId() == null && expenseAccountDO.getTopOrganizationId() == null) {
|
||||||
|
// 查询所有组织的数据时,不应该通过创建者或更新者来过滤,清空这些字段
|
||||||
|
log.info("查询所有组织数据,清空 createByName 和 updateByName 过滤条件,避免限制查询结果");
|
||||||
|
expenseAccountDO.setCreateByName(null);
|
||||||
|
expenseAccountDO.setUpdateByName(null);
|
||||||
|
} else if (expenseAccountDO.getOrganizationId() != null && loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织查询指定组织时,如果 createByName 或 updateByName 等于当前登录用户名,说明可能是 Assembler 自动设置的
|
||||||
|
// 清空这些字段,避免限制查询结果(因为其他组织的数据可能不是当前登录用户创建的)
|
||||||
|
if (currentUserName != null) {
|
||||||
|
if (expenseAccountDO.getCreateByName() != null && expenseAccountDO.getCreateByName().equals(currentUserName)) {
|
||||||
|
log.info("南光组织查询指定组织数据(organizationId={}),清空 createByName 过滤条件(可能由 Assembler 自动设置)",
|
||||||
|
expenseAccountDO.getOrganizationId());
|
||||||
|
expenseAccountDO.setCreateByName(null);
|
||||||
|
}
|
||||||
|
if (expenseAccountDO.getUpdateByName() != null && expenseAccountDO.getUpdateByName().equals(currentUserName)) {
|
||||||
|
log.info("南光组织查询指定组织数据(organizationId={}),清空 updateByName 过滤条件(可能由 Assembler 自动设置)",
|
||||||
|
expenseAccountDO.getOrganizationId());
|
||||||
|
expenseAccountDO.setUpdateByName(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("设置组织ID后,查询参数:organizationId={}, topOrganizationId={}, createByName={}, updateByName={}",
|
||||||
|
expenseAccountDO.getOrganizationId(), expenseAccountDO.getTopOrganizationId(),
|
||||||
|
expenseAccountDO.getCreateByName(), expenseAccountDO.getUpdateByName());
|
||||||
|
List<ExpenseAccountPO> result = expenseAccountDomainService.queryList(expenseAccountDO);
|
||||||
|
log.info("查询费用科目列表成功,返回数据条数:{}", result != null ? result.size() : 0);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询费用科目列表异常", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExpenseAccountPO> treeCostSubject(ExpenseAccountDO expenseAccountDO){
|
public List<ExpenseAccountPO> treeCostSubject(ExpenseAccountDO expenseAccountDO){
|
||||||
setTopOrganizationIdLogin(expenseAccountDO);
|
setDataPermission(expenseAccountDO);
|
||||||
return expenseAccountDomainService.treeCostSubject(expenseAccountDO);
|
return expenseAccountDomainService.treeCostSubject(expenseAccountDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExpenseAccountPO> subjectTreeCost(ExpenseAccountDO expenseAccountDO){
|
public List<ExpenseAccountPO> subjectTreeCost(ExpenseAccountDO expenseAccountDO){
|
||||||
setTopOrganizationIdLogin(expenseAccountDO);
|
setDataPermission(expenseAccountDO);
|
||||||
return expenseAccountDomainService.treeCostSubject(expenseAccountDO);
|
return expenseAccountDomainService.treeCostSubject(expenseAccountDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private void setTopOrganizationIdLogin(ExpenseAccountDO expenseAccountDO){
|
* 根据当前登录用户的组织信息实现数据隔离
|
||||||
|
* 当前登录用户为组织ID字段organization_id为2827时可查全部组织数据,其他组织只能查自己
|
||||||
|
*/
|
||||||
|
private void setDataPermission(ExpenseAccountDO expenseAccountDO){
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser != null){
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
log.warn("费用科目查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
if (topOrganizationId != null && topOrganizationId != 1){
|
return;
|
||||||
expenseAccountDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
}
|
||||||
|
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = expenseAccountDO.getOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
expenseAccountDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
expenseAccountDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
expenseAccountDO.setOrganizationId(null);
|
||||||
|
expenseAccountDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置 organizationId,只查询当前组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
log.warn("费用科目查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
expenseAccountDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
expenseAccountDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
expenseAccountDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
expenseAccountDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
expenseAccountDO.setTopOrganizationId(topOrganizationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,13 +376,44 @@ public class ExpenseAccountApplicationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<QueryExpenseAccountPO> selectExpenseAccount(SearchExpenseAccountDO searchExpenseAccountDO){
|
public List<QueryExpenseAccountPO> selectExpenseAccount(SearchExpenseAccountDO searchExpenseAccountDO){
|
||||||
|
setDataPermissionForSearch(searchExpenseAccountDO);
|
||||||
return expenseAccountDomainService.selectExpenseAccount(searchExpenseAccountDO);
|
return expenseAccountDomainService.selectExpenseAccount(searchExpenseAccountDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QueryExpenseAccountPO> selectOtherExpenseAccount(SearchExpenseAccountDO searchExpenseAccountDO){
|
public List<QueryExpenseAccountPO> selectOtherExpenseAccount(SearchExpenseAccountDO searchExpenseAccountDO){
|
||||||
|
setDataPermissionForSearch(searchExpenseAccountDO);
|
||||||
return expenseAccountDomainService.selectOtherExpenseAccount(searchExpenseAccountDO);
|
return expenseAccountDomainService.selectOtherExpenseAccount(searchExpenseAccountDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为 SearchExpenseAccountDO 设置数据权限
|
||||||
|
*/
|
||||||
|
private void setDataPermissionForSearch(SearchExpenseAccountDO searchExpenseAccountDO) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("费用科目查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据,不设置组织过滤条件
|
||||||
|
searchExpenseAccountDO.setOrganizationId(null);
|
||||||
|
searchExpenseAccountDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 其他组织:只查询当前组织的数据
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
searchExpenseAccountDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
searchExpenseAccountDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<QueryExpenseAccountPO> selectSocialVehicleExpenseAccount(){
|
public List<QueryExpenseAccountPO> selectSocialVehicleExpenseAccount(){
|
||||||
return expenseAccountDomainService.selectSocialVehicleExpenseAccount();
|
return expenseAccountDomainService.selectSocialVehicleExpenseAccount();
|
||||||
}
|
}
|
||||||
|
|||||||
+178
-12
@@ -35,24 +35,190 @@ public class ServiceItemsManageApplicationService {
|
|||||||
/**
|
/**
|
||||||
* 分页查询服务项管理列表
|
* 分页查询服务项管理列表
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public List<ServiceItemsManagePO> queryList(ServiceItemsManageDO serviceItemsManageDO) {
|
public List<ServiceItemsManagePO> queryList(ServiceItemsManageDO serviceItemsManageDO) {
|
||||||
setTopOrganizationIdLogin(serviceItemsManageDO);
|
try {
|
||||||
return serviceItemsManageDomainService.queryList(serviceItemsManageDO);
|
log.info("开始查询服务项管理列表,参数:organizationId={}, topOrganizationId={}, serviceItemsManageDO={}",
|
||||||
|
serviceItemsManageDO.getOrganizationId(), serviceItemsManageDO.getTopOrganizationId(), serviceItemsManageDO);
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId 和 topOrganizationId(如果存在)
|
||||||
|
// 注意:这里需要在设置权限逻辑之前保存,因为 Assembler 可能已经设置了这些值
|
||||||
|
Long frontendOrganizationId = serviceItemsManageDO.getOrganizationId();
|
||||||
|
Long frontendTopOrganizationId = serviceItemsManageDO.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 获取登录用户信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
Long loginUserOrganizationId = null;
|
||||||
|
Long loginUserTopOrganizationId = null;
|
||||||
|
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
loginUserTopOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("登录用户信息:loginUserOrganizationId={}, loginUserTopOrganizationId={}, 前端传递:frontendOrganizationId={}, frontendTopOrganizationId={}",
|
||||||
|
loginUserOrganizationId, loginUserTopOrganizationId, frontendOrganizationId, frontendTopOrganizationId);
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||||
|
serviceItemsManageDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||||
|
log.info("南光组织查询指定组织:organizationId={}", frontendOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
serviceItemsManageDO.setOrganizationId(null);
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(null);
|
||||||
|
log.info("南光组织查询所有组织:不设置组织过滤条件");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("服务项管理查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
serviceItemsManageDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
serviceItemsManageDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
if (loginUserTopOrganizationId != null) {
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(loginUserTopOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
serviceItemsManageDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
if (loginUserTopOrganizationId != null) {
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(loginUserTopOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理 createByName 和 updateByName 字段:
|
||||||
|
// 问题:Assembler 在查询场景下(serviceItemsManageId == null)会自动设置 createByName 和 updateByName 为当前登录用户名
|
||||||
|
// 这会导致 SQL 中添加 create_by_name LIKE '%nanguang%' 和 update_by_name LIKE '%nanguang%' 条件
|
||||||
|
// 解决方案:
|
||||||
|
// 1. 如果查询所有组织(organizationId 和 topOrganizationId 都为 null),清空这些字段
|
||||||
|
// 2. 如果查询指定组织(organizationId 不为 null),且是南光组织查询,如果 createByName 或 updateByName 等于当前登录用户名,清空它们
|
||||||
|
// 因为查询其他组织的数据时,不应该通过当前登录用户的名称来过滤
|
||||||
|
// 注意:这种方法可能会误判(如果前端确实传递了当前登录用户名作为查询条件),但这种情况很少见,且影响较小
|
||||||
|
|
||||||
|
String currentUserName = null;
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
currentUserName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceItemsManageDO.getOrganizationId() == null && serviceItemsManageDO.getTopOrganizationId() == null) {
|
||||||
|
// 查询所有组织的数据时,不应该通过创建者或更新者来过滤,清空这些字段
|
||||||
|
log.info("查询所有组织数据,清空 createByName 和 updateByName 过滤条件,避免限制查询结果");
|
||||||
|
serviceItemsManageDO.setCreateByName(null);
|
||||||
|
serviceItemsManageDO.setUpdateByName(null);
|
||||||
|
} else if (serviceItemsManageDO.getOrganizationId() != null && loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织查询指定组织时,如果 createByName 或 updateByName 等于当前登录用户名,说明可能是 Assembler 自动设置的
|
||||||
|
// 清空这些字段,避免限制查询结果(因为其他组织的数据可能不是当前登录用户创建的)
|
||||||
|
if (currentUserName != null) {
|
||||||
|
if (serviceItemsManageDO.getCreateByName() != null && serviceItemsManageDO.getCreateByName().equals(currentUserName)) {
|
||||||
|
log.info("南光组织查询指定组织数据(organizationId={}),清空 createByName 过滤条件(可能由 Assembler 自动设置)",
|
||||||
|
serviceItemsManageDO.getOrganizationId());
|
||||||
|
serviceItemsManageDO.setCreateByName(null);
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getUpdateByName() != null && serviceItemsManageDO.getUpdateByName().equals(currentUserName)) {
|
||||||
|
log.info("南光组织查询指定组织数据(organizationId={}),清空 updateByName 过滤条件(可能由 Assembler 自动设置)",
|
||||||
|
serviceItemsManageDO.getOrganizationId());
|
||||||
|
serviceItemsManageDO.setUpdateByName(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("设置组织ID后,查询参数:organizationId={}, topOrganizationId={}, createByName={}, updateByName={}",
|
||||||
|
serviceItemsManageDO.getOrganizationId(), serviceItemsManageDO.getTopOrganizationId(),
|
||||||
|
serviceItemsManageDO.getCreateByName(), serviceItemsManageDO.getUpdateByName());
|
||||||
|
List<ServiceItemsManagePO> result = serviceItemsManageDomainService.queryList(serviceItemsManageDO);
|
||||||
|
log.info("查询服务项管理列表成功,返回数据条数:{}", result != null ? result.size() : 0);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询服务项管理列表异常", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ServiceItemsManagePO> getCostTypeList(ServiceItemsManageDO serviceItemsManageDO){
|
public List<ServiceItemsManagePO> getCostTypeList(ServiceItemsManageDO serviceItemsManageDO){
|
||||||
setTopOrganizationIdLogin(serviceItemsManageDO);
|
try {
|
||||||
return serviceItemsManageDomainService.getCostsType(serviceItemsManageDO);
|
log.info("开始查询费用类别列表,参数:{}", serviceItemsManageDO);
|
||||||
}
|
|
||||||
|
|
||||||
private void setTopOrganizationIdLogin(ServiceItemsManageDO serviceItemsManageDO){
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
Long frontendOrganizationId = serviceItemsManageDO.getOrganizationId();
|
||||||
if (loginUser != null){
|
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
// 获取登录用户信息
|
||||||
if (topOrganizationId != null && topOrganizationId != 1){
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
serviceItemsManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
Long loginUserOrganizationId = null;
|
||||||
|
Long topOrganizationId = null;
|
||||||
|
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId(包括2827),使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||||
|
serviceItemsManageDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
serviceItemsManageDO.setOrganizationId(null);
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("费用类别查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
serviceItemsManageDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
serviceItemsManageDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
serviceItemsManageDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
serviceItemsManageDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("设置组织ID后,费用类别查询参数:organizationId={}, topOrganizationId={}",
|
||||||
|
serviceItemsManageDO.getOrganizationId(), serviceItemsManageDO.getTopOrganizationId());
|
||||||
|
List<ServiceItemsManagePO> result = serviceItemsManageDomainService.getCostsType(serviceItemsManageDO);
|
||||||
|
log.info("查询费用类别列表成功,返回数据条数:{}", result != null ? result.size() : 0);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询费用类别列表异常", e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
@@ -56,6 +56,13 @@ public class WarehouseApplicationService {
|
|||||||
* 新增仓库
|
* 新增仓库
|
||||||
*/
|
*/
|
||||||
public Boolean insert(WarehouseDO warehouseDO) {
|
public Boolean insert(WarehouseDO warehouseDO) {
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
warehouseDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
warehouseDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||||
|
warehouseDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
}
|
||||||
//设置数据字典键值
|
//设置数据字典键值
|
||||||
setDataDict(warehouseDO);
|
setDataDict(warehouseDO);
|
||||||
return warehouseDomainService.insert(warehouseDO);
|
return warehouseDomainService.insert(warehouseDO);
|
||||||
|
|||||||
+3
@@ -126,4 +126,7 @@ public class CommonRouteDo extends BaseVOEntity
|
|||||||
|
|
||||||
@ApiModelProperty(name = "运费单价")
|
@ApiModelProperty(name = "运费单价")
|
||||||
private BigDecimal freightUnitPrice;
|
private BigDecimal freightUnitPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织ID(用于数据权限过滤,内部使用)", hidden = true)
|
||||||
|
private Long organizationId;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -10,6 +10,7 @@ import com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO;
|
|||||||
import com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDoMap;
|
import com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDoMap;
|
||||||
import com.mhd.basic.domain.expenseAccount.repository.todo.SearchExpenseAccountDO;
|
import com.mhd.basic.domain.expenseAccount.repository.todo.SearchExpenseAccountDO;
|
||||||
import com.mhd.basic.interfaces.dto.expenseAccount.SearchExpenseAccountDTO;
|
import com.mhd.basic.interfaces.dto.expenseAccount.SearchExpenseAccountDTO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -24,6 +25,7 @@ import java.util.List;
|
|||||||
* @author gen
|
* @author gen
|
||||||
* @date 2024-06-04
|
* @date 2024-06-04
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ExpenseAccountImpl extends ServiceImpl<ExpenseAccountMapper, ExpenseAccount> implements IExpenseAccountService{
|
public class ExpenseAccountImpl extends ServiceImpl<ExpenseAccountMapper, ExpenseAccount> implements IExpenseAccountService{
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -35,7 +37,15 @@ public class ExpenseAccountImpl extends ServiceImpl<ExpenseAccountMapper, Expens
|
|||||||
@Override
|
@Override
|
||||||
public List<ExpenseAccountPO> queryList(ExpenseAccountDO expenseAccountDO)
|
public List<ExpenseAccountPO> queryList(ExpenseAccountDO expenseAccountDO)
|
||||||
{
|
{
|
||||||
return expenseAccountMapper.queryList(expenseAccountDO);
|
// 添加日志,记录查询参数
|
||||||
|
log.info("ExpenseAccountImpl.queryList 查询参数:topOrganizationId={}, subjectName={}, subjectCode={}, status={}",
|
||||||
|
expenseAccountDO.getTopOrganizationId(),
|
||||||
|
expenseAccountDO.getSubjectName(),
|
||||||
|
expenseAccountDO.getSubjectCode(),
|
||||||
|
expenseAccountDO.getStatus());
|
||||||
|
List<ExpenseAccountPO> result = expenseAccountMapper.queryList(expenseAccountDO);
|
||||||
|
log.info("ExpenseAccountImpl.queryList 查询结果:{} 条", result != null ? result.size() : 0);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+11
@@ -39,5 +39,16 @@ public class QueryExpenseAccountPO {
|
|||||||
@Excel(name = "上级科目名称")
|
@Excel(name = "上级科目名称")
|
||||||
private String upperSubject;
|
private String upperSubject;
|
||||||
|
|
||||||
|
@ApiModelProperty("一级组织表ID")
|
||||||
|
@Excel(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
|
|
||||||
|
@ApiModelProperty("组织表ID")
|
||||||
|
@Excel(name = "组织表ID")
|
||||||
|
private Long organizationId;
|
||||||
|
|
||||||
|
@ApiModelProperty("组织名称")
|
||||||
|
@Excel(name = "组织名称")
|
||||||
|
private String organizationName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -25,4 +25,10 @@ public class SearchExpenseAccountDO{
|
|||||||
|
|
||||||
@ApiModelProperty("社会车辆固定显示(1-是,2-否)")
|
@ApiModelProperty("社会车辆固定显示(1-是,2-否)")
|
||||||
private Integer societyStatus;
|
private Integer societyStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("组织ID")
|
||||||
|
private Long organizationId;
|
||||||
|
|
||||||
|
@ApiModelProperty("上级组织ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ public interface IServiceItemsManageService extends IService<ServiceItemsManage>
|
|||||||
/**
|
/**
|
||||||
* 查询费用类别
|
* 查询费用类别
|
||||||
*/
|
*/
|
||||||
public List<ServiceItemsManagePO> getCostType();
|
public List<ServiceItemsManagePO> getCostType(ServiceItemsManageDO serviceItemsManageDO);
|
||||||
/**
|
/**
|
||||||
* 新增服务项管理
|
* 新增服务项管理
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -21,6 +21,6 @@ public interface ServiceItemsManageMapper extends BaseMapper<ServiceItemsManage>
|
|||||||
/**
|
/**
|
||||||
* 查询费用类别
|
* 查询费用类别
|
||||||
*/
|
*/
|
||||||
public List<ServiceItemsManagePO> selectServiceTypes();
|
public List<ServiceItemsManagePO> selectServiceTypes(ServiceItemsManageDO serviceItemsManageDO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+73
-3
@@ -6,6 +6,7 @@ import com.mhd.basic.domain.serviceItemsManage.entity.ServiceItemsManage;
|
|||||||
import com.mhd.basic.domain.serviceItemsManage.repository.facade.IServiceItemsManageService;
|
import com.mhd.basic.domain.serviceItemsManage.repository.facade.IServiceItemsManageService;
|
||||||
import com.mhd.basic.domain.serviceItemsManage.repository.po.ServiceItemsManagePO;
|
import com.mhd.basic.domain.serviceItemsManage.repository.po.ServiceItemsManagePO;
|
||||||
import com.mhd.basic.domain.serviceItemsManage.repository.todo.ServiceItemsManageDO;
|
import com.mhd.basic.domain.serviceItemsManage.repository.todo.ServiceItemsManageDO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -19,6 +20,7 @@ import java.util.List;
|
|||||||
* @author gen
|
* @author gen
|
||||||
* @date 2024-06-03
|
* @date 2024-06-03
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ServiceItemsManageImpl extends ServiceImpl<ServiceItemsManageMapper, ServiceItemsManage> implements IServiceItemsManageService{
|
public class ServiceItemsManageImpl extends ServiceImpl<ServiceItemsManageMapper, ServiceItemsManage> implements IServiceItemsManageService{
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -30,12 +32,80 @@ public class ServiceItemsManageImpl extends ServiceImpl<ServiceItemsManageMapper
|
|||||||
@Override
|
@Override
|
||||||
public List<ServiceItemsManagePO> queryList(ServiceItemsManageDO serviceItemsManageDO)
|
public List<ServiceItemsManagePO> queryList(ServiceItemsManageDO serviceItemsManageDO)
|
||||||
{
|
{
|
||||||
return serviceItemsManageMapper.queryList(serviceItemsManageDO);
|
// 添加日志,记录查询参数
|
||||||
|
log.info("ServiceItemsManageImpl.queryList 查询参数:topOrganizationId={}, organizationId={}, serviceItemsName={}, serviceItemsCode={}",
|
||||||
|
serviceItemsManageDO.getTopOrganizationId(),
|
||||||
|
serviceItemsManageDO.getOrganizationId(),
|
||||||
|
serviceItemsManageDO.getServiceItemsName(),
|
||||||
|
serviceItemsManageDO.getServiceItemsCode());
|
||||||
|
|
||||||
|
// 构建SQL查询条件说明(用于日志,必须与 MyBatis XML 中的条件保持一致)
|
||||||
|
StringBuilder sqlCondition = new StringBuilder("WHERE del_flag = 1");
|
||||||
|
|
||||||
|
// 组织过滤条件(与 XML 中的 <if test="organizationId != null"> 和 <if test="topOrganizationId != null and organizationId == null"> 对应)
|
||||||
|
if (serviceItemsManageDO.getOrganizationId() != null) {
|
||||||
|
// 如果设置了 organizationId,添加 organization_id 条件
|
||||||
|
sqlCondition.append(" AND organization_id = ").append(serviceItemsManageDO.getOrganizationId());
|
||||||
|
sqlCondition.append(" AND organization_name IS NOT NULL");
|
||||||
|
sqlCondition.append(" AND organization_name != ''");
|
||||||
|
sqlCondition.append(" AND LENGTH(TRIM(organization_name)) > 0");
|
||||||
|
} else if (serviceItemsManageDO.getTopOrganizationId() != null) {
|
||||||
|
// 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件
|
||||||
|
sqlCondition.append(" AND top_organization_id = ").append(serviceItemsManageDO.getTopOrganizationId());
|
||||||
|
sqlCondition.append(" AND organization_name IS NOT NULL");
|
||||||
|
sqlCondition.append(" AND organization_name != ''");
|
||||||
|
sqlCondition.append(" AND LENGTH(TRIM(organization_name)) > 0");
|
||||||
|
} else {
|
||||||
|
// 如果 organizationId 和 topOrganizationId 都为 null,不添加组织过滤条件(查询所有组织的数据)
|
||||||
|
sqlCondition.append(" (无组织过滤条件,查询所有组织的数据)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他查询条件
|
||||||
|
if (serviceItemsManageDO.getCreateByName() != null && !serviceItemsManageDO.getCreateByName().isEmpty()) {
|
||||||
|
sqlCondition.append(" AND create_by_name LIKE '%").append(serviceItemsManageDO.getCreateByName()).append("%'");
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getUpdateByName() != null && !serviceItemsManageDO.getUpdateByName().isEmpty()) {
|
||||||
|
sqlCondition.append(" AND update_by_name LIKE '%").append(serviceItemsManageDO.getUpdateByName()).append("%'");
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getOrganizationName() != null && !serviceItemsManageDO.getOrganizationName().isEmpty()) {
|
||||||
|
sqlCondition.append(" AND organization_name LIKE '%").append(serviceItemsManageDO.getOrganizationName()).append("%'");
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getServiceItemsName() != null && !serviceItemsManageDO.getServiceItemsName().isEmpty()) {
|
||||||
|
sqlCondition.append(" AND service_items_name LIKE '%").append(serviceItemsManageDO.getServiceItemsName()).append("%'");
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getServiceItemsCode() != null && !serviceItemsManageDO.getServiceItemsCode().isEmpty()) {
|
||||||
|
sqlCondition.append(" AND service_items_code = '").append(serviceItemsManageDO.getServiceItemsCode()).append("'");
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getTaxRate() != null) {
|
||||||
|
sqlCondition.append(" AND tax_rate = ").append(serviceItemsManageDO.getTaxRate());
|
||||||
|
}
|
||||||
|
if (serviceItemsManageDO.getRemark() != null && !serviceItemsManageDO.getRemark().isEmpty()) {
|
||||||
|
sqlCondition.append(" AND remark LIKE '%").append(serviceItemsManageDO.getRemark()).append("%'");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("ServiceItemsManageImpl.queryList 生成的SQL条件(预估):SELECT * FROM service_items_manage {}", sqlCondition.toString());
|
||||||
|
log.info("ServiceItemsManageImpl.queryList 实际执行的SQL请查看 MyBatis 日志,参数:organizationId={}, topOrganizationId={}, delFlag={}",
|
||||||
|
serviceItemsManageDO.getOrganizationId(), serviceItemsManageDO.getTopOrganizationId(), serviceItemsManageDO.getDelFlag());
|
||||||
|
|
||||||
|
List<ServiceItemsManagePO> result = serviceItemsManageMapper.queryList(serviceItemsManageDO);
|
||||||
|
log.info("ServiceItemsManageImpl.queryList 查询结果:{} 条", result != null ? result.size() : 0);
|
||||||
|
// 记录查询结果中的组织ID分布
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
StringBuilder orgIds = new StringBuilder();
|
||||||
|
for (ServiceItemsManagePO po : result) {
|
||||||
|
if (orgIds.length() > 0) {
|
||||||
|
orgIds.append(", ");
|
||||||
|
}
|
||||||
|
orgIds.append(po.getOrganizationId());
|
||||||
|
}
|
||||||
|
log.info("查询结果中的组织ID分布:{}", orgIds.toString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ServiceItemsManagePO> getCostType() {
|
public List<ServiceItemsManagePO> getCostType(ServiceItemsManageDO serviceItemsManageDO) {
|
||||||
return serviceItemsManageMapper.selectServiceTypes();
|
return serviceItemsManageMapper.selectServiceTypes(serviceItemsManageDO);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 新增服务项管理
|
* 新增服务项管理
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ public class ServiceItemsManageDomainService {
|
|||||||
* 查询费用类型
|
* 查询费用类型
|
||||||
*/
|
*/
|
||||||
public List<ServiceItemsManagePO> getCostsType(ServiceItemsManageDO serviceItemsManageDO){
|
public List<ServiceItemsManagePO> getCostsType(ServiceItemsManageDO serviceItemsManageDO){
|
||||||
return serviceItemsManageService.getCostType();
|
return serviceItemsManageService.getCostType(serviceItemsManageDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+36
-17
@@ -27,8 +27,10 @@ public class ExpenseAccountAssembler {
|
|||||||
*/
|
*/
|
||||||
public ExpenseAccountDO toDO(ExpenseAccountDTO expenseAccountDTO) {
|
public ExpenseAccountDO toDO(ExpenseAccountDTO expenseAccountDTO) {
|
||||||
ExpenseAccountDO expenseAccountDO = new ExpenseAccountDO();
|
ExpenseAccountDO expenseAccountDO = new ExpenseAccountDO();
|
||||||
// 拷贝
|
// 如果 expenseAccountDTO 不为 null,才进行拷贝
|
||||||
BeanUtils.copyProperties(expenseAccountDTO, expenseAccountDO, IgnoreNullUtil.getNullPropertyNames(expenseAccountDTO));
|
if (expenseAccountDTO != null) {
|
||||||
|
BeanUtils.copyProperties(expenseAccountDTO, expenseAccountDO, IgnoreNullUtil.getNullPropertyNames(expenseAccountDTO));
|
||||||
|
}
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
@@ -36,28 +38,45 @@ public class ExpenseAccountAssembler {
|
|||||||
String userName = loginUser.getUsername();
|
String userName = loginUser.getUsername();
|
||||||
// 获取登录人id
|
// 获取登录人id
|
||||||
Long userId = loginUser.getUserid();
|
Long userId = loginUser.getUserid();
|
||||||
if(expenseAccountDTO.getExpenseAccountId() != null){
|
|
||||||
if(userId != null){
|
|
||||||
expenseAccountDO.setUpdateBy(userId);
|
|
||||||
}else {
|
|
||||||
expenseAccountDO.setUpdateBy(new Long("0"));
|
|
||||||
}
|
|
||||||
expenseAccountDO.setUpdateByName(userName);
|
|
||||||
expenseAccountDO.setUpdateTime(new Date());
|
|
||||||
|
|
||||||
}else {
|
// 只有在新增或编辑操作时才设置 createByName 和 updateByName
|
||||||
|
// 查询列表时不应该自动设置这些字段,否则会导致 SQL 中添加过滤条件,影响查询结果
|
||||||
|
if(expenseAccountDTO != null && expenseAccountDTO.getExpenseAccountId() != null){
|
||||||
|
// 编辑操作:只设置更新相关字段
|
||||||
if(userId != null){
|
if(userId != null){
|
||||||
expenseAccountDO.setCreateBy(userId);
|
|
||||||
expenseAccountDO.setUpdateBy(userId);
|
expenseAccountDO.setUpdateBy(userId);
|
||||||
}else {
|
}else {
|
||||||
expenseAccountDO.setCreateBy(new Long("0"));
|
|
||||||
expenseAccountDO.setUpdateBy(new Long("0"));
|
expenseAccountDO.setUpdateBy(new Long("0"));
|
||||||
}
|
}
|
||||||
expenseAccountDO.setCreateByName(userName);
|
// 只有在 DTO 中没有传递 updateByName 时才设置(避免覆盖前端传递的值)
|
||||||
expenseAccountDO.setUpdateByName(userName);
|
if(expenseAccountDO.getUpdateByName() == null || expenseAccountDO.getUpdateByName().isEmpty()){
|
||||||
expenseAccountDO.setCreateTime(new Date());
|
expenseAccountDO.setUpdateByName(userName);
|
||||||
|
}
|
||||||
expenseAccountDO.setUpdateTime(new Date());
|
expenseAccountDO.setUpdateTime(new Date());
|
||||||
expenseAccountDO.setDelFlag(1);
|
} else if(expenseAccountDTO != null && expenseAccountDTO.getExpenseAccountId() == null) {
|
||||||
|
// expenseAccountId == null,可能是查询操作或新增操作
|
||||||
|
// 如果前端传递了 createByName 或 updateByName,说明是查询条件,不应该设置(已经在 BeanUtils.copyProperties 中拷贝了)
|
||||||
|
// 如果前端没有传递 createByName 和 updateByName,可能是新增操作,需要设置默认值
|
||||||
|
boolean hasQueryCondition = (expenseAccountDTO.getCreateByName() != null && !expenseAccountDTO.getCreateByName().isEmpty())
|
||||||
|
|| (expenseAccountDTO.getUpdateByName() != null && !expenseAccountDTO.getUpdateByName().isEmpty());
|
||||||
|
|
||||||
|
if(!hasQueryCondition) {
|
||||||
|
// 没有查询条件,可能是新增操作,设置默认值
|
||||||
|
if(userId != null){
|
||||||
|
expenseAccountDO.setCreateBy(userId);
|
||||||
|
expenseAccountDO.setUpdateBy(userId);
|
||||||
|
}else {
|
||||||
|
expenseAccountDO.setCreateBy(new Long("0"));
|
||||||
|
expenseAccountDO.setUpdateBy(new Long("0"));
|
||||||
|
}
|
||||||
|
expenseAccountDO.setCreateByName(userName);
|
||||||
|
expenseAccountDO.setUpdateByName(userName);
|
||||||
|
expenseAccountDO.setCreateTime(new Date());
|
||||||
|
expenseAccountDO.setUpdateTime(new Date());
|
||||||
|
expenseAccountDO.setDelFlag(1);
|
||||||
|
}
|
||||||
|
// 如果有查询条件(createByName 或 updateByName),说明是查询操作,不应该设置这些字段
|
||||||
|
// 字段值已经在 BeanUtils.copyProperties 中从 DTO 拷贝过来了
|
||||||
}
|
}
|
||||||
return expenseAccountDO;
|
return expenseAccountDO;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-17
@@ -27,8 +27,10 @@ public class ServiceItemsManageAssembler {
|
|||||||
*/
|
*/
|
||||||
public ServiceItemsManageDO toDO(ServiceItemsManageDTO serviceItemsManageDTO) {
|
public ServiceItemsManageDO toDO(ServiceItemsManageDTO serviceItemsManageDTO) {
|
||||||
ServiceItemsManageDO serviceItemsManageDO = new ServiceItemsManageDO();
|
ServiceItemsManageDO serviceItemsManageDO = new ServiceItemsManageDO();
|
||||||
// 拷贝
|
// 如果 serviceItemsManageDTO 不为 null,才进行拷贝
|
||||||
BeanUtils.copyProperties(serviceItemsManageDTO, serviceItemsManageDO, IgnoreNullUtil.getNullPropertyNames(serviceItemsManageDTO));
|
if (serviceItemsManageDTO != null) {
|
||||||
|
BeanUtils.copyProperties(serviceItemsManageDTO, serviceItemsManageDO, IgnoreNullUtil.getNullPropertyNames(serviceItemsManageDTO));
|
||||||
|
}
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
@@ -36,28 +38,49 @@ public class ServiceItemsManageAssembler {
|
|||||||
String userName = loginUser.getUsername();
|
String userName = loginUser.getUsername();
|
||||||
// 获取登录人id
|
// 获取登录人id
|
||||||
Long userId = loginUser.getUserid();
|
Long userId = loginUser.getUserid();
|
||||||
if(serviceItemsManageDTO.getServiceItemsManageId() != null){
|
|
||||||
if(userId != null){
|
|
||||||
serviceItemsManageDO.setUpdateBy(userId);
|
|
||||||
}else {
|
|
||||||
serviceItemsManageDO.setUpdateBy(new Long("0"));
|
|
||||||
}
|
|
||||||
serviceItemsManageDO.setUpdateByName(userName);
|
|
||||||
serviceItemsManageDO.setUpdateTime(new Date());
|
|
||||||
|
|
||||||
}else {
|
// 只有在新增或编辑操作时才设置 createByName 和 updateByName
|
||||||
|
// 查询列表时不应该自动设置这些字段,否则会导致 SQL 中添加过滤条件,影响查询结果
|
||||||
|
// 判断规则:
|
||||||
|
// 1. 如果 serviceItemsManageId != null,说明是编辑操作,只设置更新相关字段
|
||||||
|
// 2. 如果 serviceItemsManageId == null 且前端传递了 createByName 或 updateByName,说明是查询条件,不应该覆盖
|
||||||
|
// 3. 如果 serviceItemsManageId == null 且前端没有传递 createByName 和 updateByName,可能是新增操作,设置默认值
|
||||||
|
if(serviceItemsManageDTO != null && serviceItemsManageDTO.getServiceItemsManageId() != null){
|
||||||
|
// 编辑操作:只设置更新相关字段
|
||||||
if(userId != null){
|
if(userId != null){
|
||||||
serviceItemsManageDO.setCreateBy(userId);
|
|
||||||
serviceItemsManageDO.setUpdateBy(userId);
|
serviceItemsManageDO.setUpdateBy(userId);
|
||||||
}else {
|
}else {
|
||||||
serviceItemsManageDO.setCreateBy(new Long("0"));
|
|
||||||
serviceItemsManageDO.setUpdateBy(new Long("0"));
|
serviceItemsManageDO.setUpdateBy(new Long("0"));
|
||||||
}
|
}
|
||||||
serviceItemsManageDO.setCreateByName(userName);
|
// 只有在 DTO 中没有传递 updateByName 时才设置(避免覆盖前端传递的值)
|
||||||
serviceItemsManageDO.setUpdateByName(userName);
|
if(serviceItemsManageDO.getUpdateByName() == null || serviceItemsManageDO.getUpdateByName().isEmpty()){
|
||||||
serviceItemsManageDO.setCreateTime(new Date());
|
serviceItemsManageDO.setUpdateByName(userName);
|
||||||
|
}
|
||||||
serviceItemsManageDO.setUpdateTime(new Date());
|
serviceItemsManageDO.setUpdateTime(new Date());
|
||||||
serviceItemsManageDO.setDelFlag(1);
|
} else if(serviceItemsManageDTO != null && serviceItemsManageDTO.getServiceItemsManageId() == null) {
|
||||||
|
// serviceItemsManageId == null,可能是查询操作或新增操作
|
||||||
|
// 如果前端传递了 createByName 或 updateByName,说明是查询条件,不应该设置(已经在 BeanUtils.copyProperties 中拷贝了)
|
||||||
|
// 如果前端没有传递 createByName 和 updateByName,可能是新增操作,需要设置默认值
|
||||||
|
boolean hasQueryCondition = (serviceItemsManageDTO.getCreateByName() != null && !serviceItemsManageDTO.getCreateByName().isEmpty())
|
||||||
|
|| (serviceItemsManageDTO.getUpdateByName() != null && !serviceItemsManageDTO.getUpdateByName().isEmpty());
|
||||||
|
|
||||||
|
if(!hasQueryCondition) {
|
||||||
|
// 没有查询条件,可能是新增操作,设置默认值
|
||||||
|
if(userId != null){
|
||||||
|
serviceItemsManageDO.setCreateBy(userId);
|
||||||
|
serviceItemsManageDO.setUpdateBy(userId);
|
||||||
|
}else {
|
||||||
|
serviceItemsManageDO.setCreateBy(new Long("0"));
|
||||||
|
serviceItemsManageDO.setUpdateBy(new Long("0"));
|
||||||
|
}
|
||||||
|
serviceItemsManageDO.setCreateByName(userName);
|
||||||
|
serviceItemsManageDO.setUpdateByName(userName);
|
||||||
|
serviceItemsManageDO.setCreateTime(new Date());
|
||||||
|
serviceItemsManageDO.setUpdateTime(new Date());
|
||||||
|
serviceItemsManageDO.setDelFlag(1);
|
||||||
|
}
|
||||||
|
// 如果有查询条件(createByName 或 updateByName),说明是查询操作,不应该设置这些字段
|
||||||
|
// 字段值已经在 BeanUtils.copyProperties 中从 DTO 拷贝过来了
|
||||||
}
|
}
|
||||||
return serviceItemsManageDO;
|
return serviceItemsManageDO;
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-5
@@ -52,11 +52,29 @@ public class ExpenseAccountApi extends BaseController{
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(ExpenseAccountDTO expenseAccountDTO)
|
public TableDataInfo list(ExpenseAccountDTO expenseAccountDTO)
|
||||||
{
|
{
|
||||||
//转换实体
|
logger.info("收到查询费用科目列表请求,参数:{}", expenseAccountDTO);
|
||||||
ExpenseAccountDO expenseAccountDO = expenseAccountAssembler.toDO(expenseAccountDTO);
|
try {
|
||||||
startPage();
|
//转换实体,如果 expenseAccountDTO 为 null,创建一个新的对象
|
||||||
List<ExpenseAccountPO> list = expenseAccountApplicationService.queryList(expenseAccountDO);
|
if (expenseAccountDTO == null) {
|
||||||
return getDataTable(list);
|
expenseAccountDTO = new ExpenseAccountDTO();
|
||||||
|
logger.info("expenseAccountDTO 为 null,创建新对象");
|
||||||
|
}
|
||||||
|
ExpenseAccountDO expenseAccountDO = expenseAccountAssembler.toDO(expenseAccountDTO);
|
||||||
|
logger.info("转换后的 ExpenseAccountDO:{}", expenseAccountDO);
|
||||||
|
startPage();
|
||||||
|
logger.info("分页参数已设置");
|
||||||
|
List<ExpenseAccountPO> list = expenseAccountApplicationService.queryList(expenseAccountDO);
|
||||||
|
logger.info("查询完成,返回数据条数:{}", list != null ? list.size() : 0);
|
||||||
|
if (list != null && list.isEmpty()) {
|
||||||
|
logger.warn("查询结果为空,可能的原因:1.数据库中没有符合条件的数据 2.数据权限过滤 3.SQL查询条件问题");
|
||||||
|
logger.warn("查询条件:topOrganizationId={}, del_flag=1", expenseAccountDO.getTopOrganizationId());
|
||||||
|
}
|
||||||
|
return getDataTable(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询费用科目列表失败", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
return getDataTable(new ArrayList<>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询费用科目树型列表")
|
@ApiOperation("查询费用科目树型列表")
|
||||||
@@ -84,6 +102,32 @@ public class ExpenseAccountApi extends BaseController{
|
|||||||
return AjaxResult.success(expenseAccountApplicationService.selectOtherExpenseAccount(searchExpenseAccountDO));
|
return AjaxResult.success(expenseAccountApplicationService.selectOtherExpenseAccount(searchExpenseAccountDO));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 测试查询 - 不设置组织ID,查看是否有数据
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试查询费用科目列表(不设置组织ID)")
|
||||||
|
@GetMapping("/testList")
|
||||||
|
public AjaxResult testList(ExpenseAccountDTO expenseAccountDTO)
|
||||||
|
{
|
||||||
|
logger.info("测试查询费用科目列表,不设置组织ID");
|
||||||
|
try {
|
||||||
|
if (expenseAccountDTO == null) {
|
||||||
|
expenseAccountDTO = new ExpenseAccountDTO();
|
||||||
|
}
|
||||||
|
ExpenseAccountDO expenseAccountDO = expenseAccountAssembler.toDO(expenseAccountDTO);
|
||||||
|
// 不设置组织ID,测试是否能查询到数据
|
||||||
|
expenseAccountDO.setTopOrganizationId(null);
|
||||||
|
logger.info("测试查询参数:{}", expenseAccountDO);
|
||||||
|
startPage();
|
||||||
|
List<ExpenseAccountPO> list = expenseAccountApplicationService.queryList(expenseAccountDO);
|
||||||
|
logger.info("测试查询结果:{} 条", list != null ? list.size() : 0);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("测试查询失败", e);
|
||||||
|
return AjaxResult.error("测试查询失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("查询费用科目-所有现金明细")
|
@ApiOperation("查询费用科目-所有现金明细")
|
||||||
@GetMapping("/selectAllCashExpenseAccount")
|
@GetMapping("/selectAllCashExpenseAccount")
|
||||||
public AjaxResult selectAllCashExpenseAccount(){
|
public AjaxResult selectAllCashExpenseAccount(){
|
||||||
|
|||||||
+34
-7
@@ -85,12 +85,25 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||||||
if (ObjectUtil.isNull(loginUser)) {
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
}
|
}
|
||||||
|
// 数据权限验证:南光组织(organizationId=2827)可以删除所有组织的数据,其他组织只能删除自己组织的数据
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
Long loginUserTopOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
|
||||||
for (Long dictCode : dictCodes)
|
for (Long dictCode : dictCodes)
|
||||||
{
|
{
|
||||||
SysDictData data = selectDictDataById(dictCode);
|
SysDictData data = selectDictDataById(dictCode);
|
||||||
if (ObjectUtil.notEqual(data.getTopOrganizationId(), loginUser.getUserPo().getTopOrganizationId())) {
|
|
||||||
throw new ServiceException("修改失败");
|
// 南光组织(organizationId=2827)可以删除所有组织的数据
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织可以删除,不需要验证 topOrganizationId
|
||||||
|
} else {
|
||||||
|
// 其他组织:只能删除自己组织的数据
|
||||||
|
// 使用 Objects.equals 安全比较,处理 null 值的情况
|
||||||
|
if (!java.util.Objects.equals(data.getTopOrganizationId(), loginUserTopOrganizationId)) {
|
||||||
|
throw new ServiceException("删除失败:无权删除其他组织的字典数据");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dictDataMapper.deleteDictDataById(dictCode);
|
dictDataMapper.deleteDictDataById(dictCode);
|
||||||
SysDictData dictData = new SysDictData();
|
SysDictData dictData = new SysDictData();
|
||||||
dictData.setDictType(data.getDictType());
|
dictData.setDictType(data.getDictType());
|
||||||
@@ -146,11 +159,25 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||||||
if (ObjectUtil.isNull(sysDictData)) {
|
if (ObjectUtil.isNull(sysDictData)) {
|
||||||
throw new ServiceException("字典数据未找到");
|
throw new ServiceException("字典数据未找到");
|
||||||
}
|
}
|
||||||
if ("Y".equals(sysDictData.getIsDefault())) {
|
|
||||||
throw new ServiceException("默认数据不允许修改");
|
// 数据权限验证:南光组织(organizationId=2827)可以修改所有组织的数据(包括默认数据),其他组织只能修改自己组织的数据(包括默认数据)
|
||||||
}
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
if (ObjectUtil.notEqual(sysDictData.getTopOrganizationId(), loginUser.getUserPo().getTopOrganizationId())) {
|
Long loginUserTopOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
throw new ServiceException("修改失败");
|
Long dictDataTopOrganizationId = sysDictData.getTopOrganizationId();
|
||||||
|
Long dictDataOrganizationId = sysDictData.getOrganizationId();
|
||||||
|
|
||||||
|
// 南光组织(organizationId=2827)可以修改所有组织的数据(包括默认数据)
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织可以修改,不需要验证 topOrganizationId
|
||||||
|
} else {
|
||||||
|
// 其他组织:只能修改自己组织的数据(包括默认数据)
|
||||||
|
// 使用 Objects.equals 安全比较,处理 null 值的情况
|
||||||
|
boolean isSameTopOrg = java.util.Objects.equals(dictDataTopOrganizationId, loginUserTopOrganizationId);
|
||||||
|
boolean isSameOrg = java.util.Objects.equals(dictDataOrganizationId, loginUserOrganizationId);
|
||||||
|
|
||||||
|
if (!isSameTopOrg || !isSameOrg) {
|
||||||
|
throw new ServiceException("修改失败:无权修改其他组织的字典数据");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data.setUpdateBy(loginUser.getUserPo().getUserName());
|
data.setUpdateBy(loginUser.getUserPo().getUserName());
|
||||||
int row = dictDataMapper.updateDictData(data);
|
int row = dictDataMapper.updateDictData(data);
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ 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.102.192.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
|
||||||
# server-addr: 10.102.192.105:6848
|
|
||||||
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.102.192.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
|
||||||
# server-addr: 10.102.192.105:6848
|
|
||||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||||
file-extension: yml #默认properties
|
file-extension: yml #默认properties
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
WHERE
|
WHERE
|
||||||
a.del_flag = 1
|
a.del_flag = 1
|
||||||
<include refid="common_where"/>
|
<include refid="common_where"/>
|
||||||
order by account_type,service_items_code,upper_subject_code,show_seq
|
order by a.account_type,service_items_code,upper_subject_code,show_seq
|
||||||
</select>
|
</select>
|
||||||
<select id="selectCostSubject" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO"
|
<select id="selectCostSubject" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO"
|
||||||
resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO">
|
resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO">
|
||||||
@@ -191,8 +191,24 @@
|
|||||||
<if test="expenseAccountDO.updateTimeEnd != null and expenseAccountDO.updateTimeEnd != ''">
|
<if test="expenseAccountDO.updateTimeEnd != null and expenseAccountDO.updateTimeEnd != ''">
|
||||||
AND date_format(a.update_time,'%Y-%m-%d') <![CDATA[<=]]> #{expenseAccountDO.updateTimeEnd}
|
AND date_format(a.update_time,'%Y-%m-%d') <![CDATA[<=]]> #{expenseAccountDO.updateTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<if test="expenseAccountDO.topOrganizationId != null ">
|
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||||
|
<!-- 如果 organizationId 和 topOrganizationId 都为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
|
||||||
|
<if test="expenseAccountDO.organizationId != null">
|
||||||
|
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||||
|
and a.organization_id = #{expenseAccountDO.organizationId}
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
|
and a.organization_name != ''
|
||||||
|
and LENGTH(TRIM(a.organization_name)) > 0
|
||||||
|
</if>
|
||||||
|
<if test="expenseAccountDO.topOrganizationId != null and expenseAccountDO.organizationId == null">
|
||||||
|
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
|
||||||
and a.top_organization_id = #{expenseAccountDO.topOrganizationId}
|
and a.top_organization_id = #{expenseAccountDO.topOrganizationId}
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
|
and a.organization_name != ''
|
||||||
|
and LENGTH(TRIM(a.organization_name)) > 0
|
||||||
|
</if>
|
||||||
|
<if test="expenseAccountDO.organizationName != null and expenseAccountDO.organizationName != ''">
|
||||||
|
and a.organization_name like concat('%', #{expenseAccountDO.organizationName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="expenseAccountDO.serviceItemsCode != null and expenseAccountDO.serviceItemsCode != ''">
|
<if test="expenseAccountDO.serviceItemsCode != null and expenseAccountDO.serviceItemsCode != ''">
|
||||||
and b.service_items_code = #{expenseAccountDO.serviceItemsCode}
|
and b.service_items_code = #{expenseAccountDO.serviceItemsCode}
|
||||||
|
|||||||
+25
-13
@@ -8,18 +8,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<sql id="selectServiceItemsManagePo1">
|
<sql id="selectServiceItemsManagePo1">
|
||||||
<where>
|
<where>
|
||||||
del_flag = 1
|
<!-- 删除标记:0-无状态,1-正常,2-已删除,查询时只查询正常的数据 -->
|
||||||
|
<choose>
|
||||||
|
<when test="delFlag != null">
|
||||||
|
and del_flag = #{delFlag}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
and del_flag = 1
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
<if test="createByName != null and createByName != ''">
|
<if test="createByName != null and createByName != ''">
|
||||||
and create_by_name like concat('%', #{createByName}, '%')
|
and create_by_name like concat('%', #{createByName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="updateByName != null and updateByName != ''">
|
<if test="updateByName != null and updateByName != ''">
|
||||||
and update_by_name like concat('%', #{updateByName}, '%')
|
and update_by_name like concat('%', #{updateByName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="topOrganizationId != null ">
|
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||||
and top_organization_id = #{topOrganizationId}
|
<!-- 如果 organizationId 和 topOrganizationId 都为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
|
||||||
</if>
|
<if test="organizationId != null">
|
||||||
<if test="organizationId != null ">
|
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||||
and organization_id = #{organizationId}
|
and organization_id = #{organizationId}
|
||||||
|
and organization_name IS NOT NULL
|
||||||
|
and organization_name != ''
|
||||||
|
and LENGTH(TRIM(organization_name)) > 0
|
||||||
|
</if>
|
||||||
|
<if test="topOrganizationId != null and organizationId == null">
|
||||||
|
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
|
||||||
|
and top_organization_id = #{topOrganizationId}
|
||||||
|
and organization_name IS NOT NULL
|
||||||
|
and organization_name != ''
|
||||||
|
and LENGTH(TRIM(organization_name)) > 0
|
||||||
</if>
|
</if>
|
||||||
<if test="organizationName != null and organizationName != ''">
|
<if test="organizationName != null and organizationName != ''">
|
||||||
and organization_name like concat('%', #{organizationName}, '%')
|
and organization_name like concat('%', #{organizationName}, '%')
|
||||||
@@ -42,12 +60,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="createTimeEnd != null and createTimeEnd != ''">
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
||||||
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{createTimeEnd}
|
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{createTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<if test="createByName != null and createByName != ''">
|
|
||||||
and create_by_name like concat('%', #{createByName}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="updateByName != null and updateByName != ''">
|
|
||||||
and update_by_name like concat('%', #{updateByName}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="updateTimeStart != null and updateTimeStart != ''">
|
<if test="updateTimeStart != null and updateTimeStart != ''">
|
||||||
AND date_format(update_time,'%Y-%m-%d') <![CDATA[>=]]> #{updateTimeStart}
|
AND date_format(update_time,'%Y-%m-%d') <![CDATA[>=]]> #{updateTimeStart}
|
||||||
</if>
|
</if>
|
||||||
@@ -63,10 +75,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="selectServiceItemsManagePo1"/>
|
<include refid="selectServiceItemsManagePo1"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectServiceTypes"
|
<select id="selectServiceTypes" parameterType="com.mhd.basic.domain.serviceItemsManage.repository.todo.ServiceItemsManageDO"
|
||||||
resultType="com.mhd.basic.domain.serviceItemsManage.repository.po.ServiceItemsManagePO">
|
resultType="com.mhd.basic.domain.serviceItemsManage.repository.po.ServiceItemsManagePO">
|
||||||
select organization_name,service_items_code,service_items_name,tax_rate,CONCAT(service_items_name,service_items_code) cost_type
|
select organization_name,service_items_code,service_items_name,tax_rate,CONCAT(service_items_name,service_items_code) cost_type
|
||||||
from service_items_manage
|
from service_items_manage
|
||||||
where del_flag = 1
|
<include refid="selectServiceItemsManagePo1"/>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
+7
@@ -9,6 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.*
|
a.*
|
||||||
from
|
from
|
||||||
common_route a
|
common_route a
|
||||||
|
<if test="commonRouteDo.organizationId != null">
|
||||||
|
LEFT JOIN "USER" u ON a.user_id = u.user_id AND u.del_flag = 0
|
||||||
|
</if>
|
||||||
WHERE
|
WHERE
|
||||||
a.del_flag = 1
|
a.del_flag = 1
|
||||||
</sql>
|
</sql>
|
||||||
@@ -26,6 +29,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and (a.mail_name like concat('%', #{commonRouteDo.synthesize}, '%') OR a.mail_phone LIKE concat('%', #{commonRouteDo.synthesize}, '%') OR a.mail_address_plot LIKE concat('%', #{commonRouteDo.synthesize}, '%')
|
and (a.mail_name like concat('%', #{commonRouteDo.synthesize}, '%') OR a.mail_phone LIKE concat('%', #{commonRouteDo.synthesize}, '%') OR a.mail_address_plot LIKE concat('%', #{commonRouteDo.synthesize}, '%')
|
||||||
OR a.addressee_name like concat('%', #{commonRouteDo.synthesize}, '%') OR a.addressee_phone LIKE concat('%', #{commonRouteDo.synthesize}, '%') OR a.addressee_address_plot LIKE concat('%', #{commonRouteDo.synthesize}, '%'))
|
OR a.addressee_name like concat('%', #{commonRouteDo.synthesize}, '%') OR a.addressee_phone LIKE concat('%', #{commonRouteDo.synthesize}, '%') OR a.addressee_address_plot LIKE concat('%', #{commonRouteDo.synthesize}, '%'))
|
||||||
</if>
|
</if>
|
||||||
|
<!-- 组织数据权限过滤:通过用户表关联来过滤组织数据 -->
|
||||||
|
<if test="commonRouteDo.organizationId != null">
|
||||||
|
and u.organization_id = #{commonRouteDo.organizationId}
|
||||||
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectCommonRouteByCommonRouteId" parameterType="java.lang.Long"
|
<select id="selectCommonRouteByCommonRouteId" parameterType="java.lang.Long"
|
||||||
|
|||||||
+28
-18
@@ -140,27 +140,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAddressBookList" parameterType="com.mhd.common.core.domain.po.AddressBookPo" resultMap="AddressBookResult">
|
<select id="selectAddressBookList" parameterType="com.mhd.common.core.domain.po.AddressBookPo" resultMap="AddressBookResult">
|
||||||
<include refid="selectAddressBookVo"/>
|
SELECT
|
||||||
|
ab.*
|
||||||
|
FROM
|
||||||
|
address_book ab
|
||||||
|
<if test="organizationId != null">
|
||||||
|
LEFT JOIN "USER" u ON ab.user_id = u.user_id AND u.del_flag = 0
|
||||||
|
</if>
|
||||||
<where>
|
<where>
|
||||||
del_flag = 1
|
ab.del_flag = 1
|
||||||
<if test="synthesize != null and synthesize != ''"> and (link_man like concat('%', #{synthesize}, '%') OR link_phone LIKE concat('%', #{synthesize}, '%') OR area_name LIKE concat('%', #{synthesize}, '%') OR address LIKE concat('%', #{synthesize}, '%') OR address_plot LIKE concat('%', #{synthesize}, '%')) </if>
|
<if test="synthesize != null and synthesize != ''"> and (ab.link_man like concat('%', #{synthesize}, '%') OR ab.link_phone LIKE concat('%', #{synthesize}, '%') OR ab.area_name LIKE concat('%', #{synthesize}, '%') OR ab.address LIKE concat('%', #{synthesize}, '%') OR ab.address_plot LIKE concat('%', #{synthesize}, '%')) </if>
|
||||||
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="userId != null "> and ab.user_id = #{userId}</if>
|
||||||
<if test="linkMan != null and linkMan != ''"> and link_man = #{linkMan}</if>
|
<if test="linkMan != null and linkMan != ''"> and ab.link_man = #{linkMan}</if>
|
||||||
<if test="linkPhone != null and linkPhone != ''"> and link_phone = #{linkPhone}</if>
|
<if test="linkPhone != null and linkPhone != ''"> and ab.link_phone = #{linkPhone}</if>
|
||||||
<if test="provinceCode != null "> and province_code = #{provinceCode}</if>
|
<if test="provinceCode != null "> and ab.province_code = #{provinceCode}</if>
|
||||||
<if test="cityCode != null "> and city_code = #{cityCode}</if>
|
<if test="cityCode != null "> and ab.city_code = #{cityCode}</if>
|
||||||
<if test="countyCode != null "> and county_code = #{countyCode}</if>
|
<if test="countyCode != null "> and ab.county_code = #{countyCode}</if>
|
||||||
<if test="provinceName != null and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
|
<if test="provinceName != null and provinceName != ''"> and ab.province_name like concat('%', #{provinceName}, '%')</if>
|
||||||
<if test="cityName != null and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
|
<if test="cityName != null and cityName != ''"> and ab.city_name like concat('%', #{cityName}, '%')</if>
|
||||||
<if test="countyName != null and countyName != ''"> and county_name like concat('%', #{countyName}, '%')</if>
|
<if test="countyName != null and countyName != ''"> and ab.county_name like concat('%', #{countyName}, '%')</if>
|
||||||
<if test="address != null and address != ''"> and address = #{address}</if>
|
<if test="address != null and address != ''"> and ab.address = #{address}</if>
|
||||||
<if test="doorplate != null and doorplate != ''"> and doorplate = #{doorplate}</if>
|
<if test="doorplate != null and doorplate != ''"> and ab.doorplate = #{doorplate}</if>
|
||||||
<if test="defaultStatus != null "> and default_status = #{defaultStatus}</if>
|
<if test="defaultStatus != null "> and ab.default_status = #{defaultStatus}</if>
|
||||||
<if test="createByName != null and createByName != ''"> and create_by_name like concat('%', #{createByName}, '%')</if>
|
<if test="createByName != null and createByName != ''"> and ab.create_by_name like concat('%', #{createByName}, '%')</if>
|
||||||
<if test="updateByName != null and updateByName != ''"> and update_by_name like concat('%', #{updateByName}, '%')</if>
|
<if test="updateByName != null and updateByName != ''"> and ab.update_by_name like concat('%', #{updateByName}, '%')</if>
|
||||||
|
<!-- 组织数据权限过滤:通过用户表关联来过滤组织数据 -->
|
||||||
|
<if test="organizationId != null">
|
||||||
|
and u.organization_id = #{organizationId}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
ORDER BY
|
ORDER BY
|
||||||
create_time DESC
|
ab.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAddressBookListByManifestId" parameterType="java.lang.Long" resultMap="AddressBookResult">
|
<select id="selectAddressBookListByManifestId" parameterType="java.lang.Long" resultMap="AddressBookResult">
|
||||||
|
|||||||
+290
-5
@@ -40,9 +40,11 @@ import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
|||||||
import com.mhd.user.domain.roleAggregate.service.RoleDomainService;
|
import com.mhd.user.domain.roleAggregate.service.RoleDomainService;
|
||||||
import com.mhd.user.domain.userAggregate.entity.DriverVehicleBind;
|
import com.mhd.user.domain.userAggregate.entity.DriverVehicleBind;
|
||||||
import com.mhd.user.domain.userAggregate.entity.UserRoleEntity;
|
import com.mhd.user.domain.userAggregate.entity.UserRoleEntity;
|
||||||
|
import com.mhd.common.core.domain.po.UserRoleMenuPO;
|
||||||
import com.mhd.user.domain.userAggregate.repository.po.UserDriverEnterprisePo;
|
import com.mhd.user.domain.userAggregate.repository.po.UserDriverEnterprisePo;
|
||||||
import com.mhd.user.domain.userAggregate.repository.po.UserDriverPo;
|
import com.mhd.user.domain.userAggregate.repository.po.UserDriverPo;
|
||||||
import com.mhd.user.domain.userAggregate.repository.todo.*;
|
import com.mhd.user.domain.userAggregate.repository.todo.*;
|
||||||
|
import com.mhd.user.domain.userAggregate.repository.todo.UserDO;
|
||||||
import com.mhd.user.domain.motorcade.service.MotorcadeRecordDomainService;
|
import com.mhd.user.domain.motorcade.service.MotorcadeRecordDomainService;
|
||||||
import com.mhd.user.domain.userAggregate.service.*;
|
import com.mhd.user.domain.userAggregate.service.*;
|
||||||
import com.mhd.user.infrastructure.feign.SpecialLogisticsFeign;
|
import com.mhd.user.infrastructure.feign.SpecialLogisticsFeign;
|
||||||
@@ -131,7 +133,55 @@ public class MotorcadeApplicationService {
|
|||||||
public List<MotorcadePo> queryList(MotorcadeDO motorcadeDo) {
|
public List<MotorcadePo> queryList(MotorcadeDO motorcadeDo) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser != null && loginUser.getUserPo() != null){
|
if (loginUser != null && loginUser.getUserPo() != null){
|
||||||
motorcadeDo.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long organizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (organizationId != null && organizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
Long frontendOrganizationId = motorcadeDo.getOrganizationId();
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
motorcadeDo.setOrganizationId(frontendOrganizationId);
|
||||||
|
motorcadeDo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
motorcadeDo.setOrganizationId(null);
|
||||||
|
motorcadeDo.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置 organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||||
|
Long frontendOrganizationId = motorcadeDo.getOrganizationId();
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(organizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("车队列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, organizationId);
|
||||||
|
motorcadeDo.setOrganizationId(organizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
motorcadeDo.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
motorcadeDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
motorcadeDo.setOrganizationId(organizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
motorcadeDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("车队列表查询 - 设置组织ID后,查询参数:organizationId={}, topOrganizationId={}",
|
||||||
|
motorcadeDo.getOrganizationId(), motorcadeDo.getTopOrganizationId());
|
||||||
}
|
}
|
||||||
return motorcadeDomainService.queryList(motorcadeDo);
|
return motorcadeDomainService.queryList(motorcadeDo);
|
||||||
}
|
}
|
||||||
@@ -656,16 +706,28 @@ public class MotorcadeApplicationService {
|
|||||||
|
|
||||||
motorcadeDo.setMotorcadeHeaderName(userPo.getUserName());
|
motorcadeDo.setMotorcadeHeaderName(userPo.getUserName());
|
||||||
motorcadeDo.setMotorcadeHeaderAccount(userPo.getUserAccount());
|
motorcadeDo.setMotorcadeHeaderAccount(userPo.getUserAccount());
|
||||||
motorcadeDo.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
motorcadeDo.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
// 设置当前登录用户的组织信息
|
||||||
motorcadeDo.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
UserPo loginUserPo = loginUser.getUserPo();
|
||||||
|
if (loginUserPo != null) {
|
||||||
|
motorcadeDo.setOrganizationId(loginUserPo.getOrganizationId());
|
||||||
|
motorcadeDo.setOrganizationName(loginUserPo.getOrganizationName());
|
||||||
|
motorcadeDo.setTopOrganizationId(loginUserPo.getTopOrganizationId());
|
||||||
|
log.info("新增车队 - 设置当前登录用户的组织信息,组织ID: {}, 组织名称: {}, 顶级组织ID: {}",
|
||||||
|
loginUserPo.getOrganizationId(), loginUserPo.getOrganizationName(), loginUserPo.getTopOrganizationId());
|
||||||
|
} else {
|
||||||
|
log.warn("新增车队 - 当前登录用户信息为空,无法设置组织信息");
|
||||||
|
}
|
||||||
|
|
||||||
motorcadeDo.setMotorcadeStatus(2L);
|
motorcadeDo.setMotorcadeStatus(2L);
|
||||||
//获取车队承运编码
|
//获取车队承运编码
|
||||||
motorcadeDo.setDriverEnterpriseCode(userPo.getUserAccount());
|
motorcadeDo.setDriverEnterpriseCode(userPo.getUserAccount());
|
||||||
|
|
||||||
|
// 设置当前登录用户的创建信息
|
||||||
motorcadeDo.setCreateBy(loginUser.getUserid());
|
motorcadeDo.setCreateBy(loginUser.getUserid());
|
||||||
motorcadeDo.setCreateByName(loginUser.getUsername());
|
motorcadeDo.setCreateByName(loginUser.getUsername());
|
||||||
motorcadeDo.setCreateTime(DateUtil.date());
|
motorcadeDo.setCreateTime(DateUtil.date());
|
||||||
|
log.info("新增车队 - 设置创建人信息,创建人ID: {}, 创建人姓名: {}", loginUser.getUserid(), loginUser.getUsername());
|
||||||
motorcadeDomainService.insert(motorcadeDo);
|
motorcadeDomainService.insert(motorcadeDo);
|
||||||
MotorcadeDriver motorcadeDriver = new MotorcadeDriverAssembler().getEntity();
|
MotorcadeDriver motorcadeDriver = new MotorcadeDriverAssembler().getEntity();
|
||||||
motorcadeDriver.setMotorcadeId(motorcadeDo.getMotorcadeId());
|
motorcadeDriver.setMotorcadeId(motorcadeDo.getMotorcadeId());
|
||||||
@@ -674,9 +736,210 @@ public class MotorcadeApplicationService {
|
|||||||
if(!flag){
|
if(!flag){
|
||||||
throw new ServiceException("新增车队失败");
|
throw new ServiceException("新增车队失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增车队时,更新车队长的用户信息(角色、用户类型、用户身份)
|
||||||
|
updateCaptainUserInfo(motorcadeDo.getMotorcadeHeaderId(), loginUser);
|
||||||
|
|
||||||
|
// 新增车队时,给车队长分配"车队长"角色
|
||||||
|
assignCaptainRoleToUser(motorcadeDo.getMotorcadeHeaderId(), loginUser);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新车队长的用户信息(角色代码、角色名称、业务类型等)
|
||||||
|
* @param captainUserId 车队长用户ID
|
||||||
|
* @param loginUser 当前登录用户
|
||||||
|
*/
|
||||||
|
private void updateCaptainUserInfo(Long captainUserId, LoginUser loginUser) {
|
||||||
|
if (captainUserId == null || loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("更新用户信息失败 - 车队长用户ID或登录用户信息为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("新增车队 - 更新车队长的用户信息,车队长用户ID: {}", captainUserId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 获取当前登录用户的角色信息,用于设置车队长的角色
|
||||||
|
Long loginUserId = loginUser.getUserPo().getUserId();
|
||||||
|
List<UserRoleMenuPO> loginUserRoleList = userRoleDomainService.selectRolesByUserId(loginUserId);
|
||||||
|
|
||||||
|
String roleCode = RoleEnum.CAPTAIN.getCode();
|
||||||
|
String roleName = RoleEnum.CAPTAIN.getName();
|
||||||
|
|
||||||
|
// 从当前登录用户的角色中查找"车队长"角色,获取角色名称
|
||||||
|
if (CollUtil.isNotEmpty(loginUserRoleList)) {
|
||||||
|
for (UserRoleMenuPO loginUserRole : loginUserRoleList) {
|
||||||
|
if (RoleEnum.CAPTAIN.getCode().equals(loginUserRole.getRoleCode())) {
|
||||||
|
roleCode = loginUserRole.getRoleCode();
|
||||||
|
roleName = loginUserRole.getRoleName();
|
||||||
|
log.info("从当前登录用户的角色中获取车队长角色信息 - 角色代码: {}, 角色名称: {}", roleCode, roleName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新车队长的用户信息
|
||||||
|
UserDO userDO = new UserDO();
|
||||||
|
userDO.setUserId(captainUserId);
|
||||||
|
userDO.setRoleCode(roleCode);
|
||||||
|
userDO.setRoleName(roleName);
|
||||||
|
|
||||||
|
// 设置业务类型:如果用户已经是司机,则设置为司机&车队长(3),否则设置为车队长(2)
|
||||||
|
UserPo captainUserPo = userApplicationService.selectByUserId(captainUserId);
|
||||||
|
if (captainUserPo != null) {
|
||||||
|
Integer businessType = captainUserPo.getBusinessType();
|
||||||
|
// 业务类型:1=客户,2=司机,3=司机&车队长,4=客户&司机
|
||||||
|
if (businessType != null && businessType == 2) {
|
||||||
|
// 如果用户已经是司机,设置为司机&车队长(3)
|
||||||
|
userDO.setBusinessType(3);
|
||||||
|
log.info("车队长用户业务类型设置为:司机&车队长(3),原业务类型:{}", businessType);
|
||||||
|
} else if (businessType != null && businessType == 4) {
|
||||||
|
// 如果用户是客户&司机,设置为客户&司机&车队长(保持为4,或者可以设置为5如果有的话)
|
||||||
|
// 这里暂时保持为4,或者根据业务需求调整
|
||||||
|
userDO.setBusinessType(4);
|
||||||
|
log.info("车队长用户业务类型保持为:客户&司机(4),原业务类型:{}", businessType);
|
||||||
|
} else {
|
||||||
|
// 如果用户不是司机,设置为车队长(2)
|
||||||
|
userDO.setBusinessType(2);
|
||||||
|
log.info("车队长用户业务类型设置为:车队长(2),原业务类型:{}", businessType);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果查询不到用户信息,默认设置为车队长(2)
|
||||||
|
userDO.setBusinessType(2);
|
||||||
|
log.warn("查询不到车队长用户信息,默认设置业务类型为:车队长(2)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置组织信息(从当前登录用户获取)
|
||||||
|
UserPo loginUserPo = loginUser.getUserPo();
|
||||||
|
if (loginUserPo != null) {
|
||||||
|
userDO.setOrganizationId(loginUserPo.getOrganizationId());
|
||||||
|
userDO.setOrganizationName(loginUserPo.getOrganizationName());
|
||||||
|
userDO.setTopOrganizationId(loginUserPo.getTopOrganizationId());
|
||||||
|
log.info("设置车队长的组织信息 - 组织ID: {}, 组织名称: {}, 顶级组织ID: {}",
|
||||||
|
loginUserPo.getOrganizationId(), loginUserPo.getOrganizationName(), loginUserPo.getTopOrganizationId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新用户信息
|
||||||
|
UserPo updateResult = userApplicationService.updateUser(userDO);
|
||||||
|
if (updateResult != null && updateResult.getUserId() != null) {
|
||||||
|
log.info("成功更新车队长的用户信息 - 用户ID: {}, 角色代码: {}, 角色名称: {}, 业务类型: {}, 组织ID: {}, 组织名称: {}",
|
||||||
|
captainUserId, roleCode, roleName, userDO.getBusinessType(),
|
||||||
|
userDO.getOrganizationId(), userDO.getOrganizationName());
|
||||||
|
} else {
|
||||||
|
log.warn("更新车队长的用户信息失败 - 更新结果为null,用户ID: {}, 请检查用户是否存在", captainUserId);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新车队长的用户信息失败 - 用户ID: {}, 错误信息: {}", captainUserId, e.getMessage(), e);
|
||||||
|
// 不抛出异常,允许继续执行,但记录详细错误信息
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将"车队长"角色分配给车队创建时的车队长用户
|
||||||
|
* 优先从当前登录用户的角色中获取"车队长"角色,如果找不到,再根据组织ID查询
|
||||||
|
* @param captainUserId 车队长用户ID
|
||||||
|
* @param loginUser 当前登录用户
|
||||||
|
*/
|
||||||
|
private void assignCaptainRoleToUser(Long captainUserId, LoginUser loginUser) {
|
||||||
|
if (captainUserId == null || loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("分配角色失败 - 车队长用户ID或登录用户信息为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("新增车队 - 分配车队长角色,车队长用户ID: {}", captainUserId);
|
||||||
|
|
||||||
|
Long loginUserId = loginUser.getUserPo().getUserId();
|
||||||
|
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 优先从当前登录用户的角色中查找"车队长"角色
|
||||||
|
List<UserRoleMenuPO> loginUserRoleList = userRoleDomainService.selectRolesByUserId(loginUserId);
|
||||||
|
RoleEntity roleEntity = null;
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(loginUserRoleList)) {
|
||||||
|
log.info("当前登录用户共有 {} 个角色,查找车队长角色", loginUserRoleList.size());
|
||||||
|
for (UserRoleMenuPO loginUserRole : loginUserRoleList) {
|
||||||
|
if (RoleEnum.CAPTAIN.getCode().equals(loginUserRole.getRoleCode())) {
|
||||||
|
// 找到"车队长"角色,使用当前登录用户的角色ID
|
||||||
|
log.info("从当前登录用户的角色中找到车队长角色 - 角色ID: {}, 角色代码: {}", loginUserRole.getRoleId(), loginUserRole.getRoleCode());
|
||||||
|
roleEntity = new RoleEntity();
|
||||||
|
roleEntity.setRoleId(loginUserRole.getRoleId());
|
||||||
|
roleEntity.setRoleCode(loginUserRole.getRoleCode());
|
||||||
|
roleEntity.setRoleName(loginUserRole.getRoleName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前登录用户没有"车队长"角色,根据组织ID查询
|
||||||
|
if (ObjectUtil.isNull(roleEntity)) {
|
||||||
|
if (organizationId == null) {
|
||||||
|
log.warn("当前登录用户的组织ID为空,无法查询车队长角色");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("当前登录用户没有车队长角色,根据组织ID查询 - 组织ID: {}, 角色代码: {}", organizationId, RoleEnum.CAPTAIN.getCode());
|
||||||
|
|
||||||
|
// 查询"车队长"角色
|
||||||
|
RoleDo roleDo = new RoleDo();
|
||||||
|
roleDo.setRoleCode(RoleEnum.CAPTAIN.getCode());
|
||||||
|
roleDo.setOrganizationId(organizationId);
|
||||||
|
|
||||||
|
roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
|
||||||
|
|
||||||
|
// 如果当前组织查询不到,尝试回退查询(不检查 organization_name IS NOT NULL)
|
||||||
|
if (ObjectUtil.isNull(roleEntity)) {
|
||||||
|
log.warn("使用 organization_name IS NOT NULL 条件查询不到角色,尝试回退查询(不检查 organization_name)- 组织ID: {}, 角色代码: {}", organizationId, RoleEnum.CAPTAIN.getCode());
|
||||||
|
com.mhd.common.core.domain.po.RolePO rolePO = roleDomainService.selectByRoleCodeAndOrganizationId(RoleEnum.CAPTAIN.getCode(), organizationId);
|
||||||
|
if (ObjectUtil.isNotNull(rolePO)) {
|
||||||
|
// 将 RolePO 转换为 RoleEntity
|
||||||
|
roleEntity = new RoleEntity();
|
||||||
|
roleEntity.setRoleId(rolePO.getRoleId());
|
||||||
|
roleEntity.setRoleCode(rolePO.getRoleCode());
|
||||||
|
roleEntity.setRoleName(rolePO.getRoleName());
|
||||||
|
roleEntity.setRoleRemark(rolePO.getRoleRemark());
|
||||||
|
roleEntity.setRoleDataScope(rolePO.getRoleDataScope());
|
||||||
|
roleEntity.setRoleStatus(rolePO.getRoleStatus());
|
||||||
|
roleEntity.setRoleType(rolePO.getRoleType());
|
||||||
|
roleEntity.setOrganizationId(rolePO.getOrganizationId());
|
||||||
|
roleEntity.setOrganizationName(rolePO.getOrganizationName());
|
||||||
|
roleEntity.setTopOrganizationId(rolePO.getTopOrganizationId());
|
||||||
|
log.info("回退查询成功找到角色 - 角色ID: {}, 角色名称: {}, 组织名称: {}", roleEntity.getRoleId(), roleEntity.getRoleName(), roleEntity.getOrganizationName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果还是查询不到,尝试使用顶级组织ID查询
|
||||||
|
if (ObjectUtil.isNull(roleEntity)) {
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
if (topOrganizationId != null && topOrganizationId.equals(organizationId)) {
|
||||||
|
log.info("当前组织查询不到角色,尝试使用顶级组织ID查询 - 顶级组织ID: {}, 角色代码: {}", topOrganizationId, RoleEnum.CAPTAIN.getCode());
|
||||||
|
roleDo.setOrganizationId(null);
|
||||||
|
roleDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(roleEntity)) {
|
||||||
|
log.info("找到车队长角色 - 角色ID: {}, 角色名称: {}", roleEntity.getRoleId(), roleEntity.getRoleName());
|
||||||
|
UserRoleDo userRoleDo = new UserRoleDo();
|
||||||
|
userRoleDo.setUserId(captainUserId);
|
||||||
|
userRoleDo.setRoleId(roleEntity.getRoleId());
|
||||||
|
|
||||||
|
// 判断是否已存在相应角色
|
||||||
|
List<UserRoleEntity> userRoleEntities = userRoleDomainService.selectList(userRoleDo);
|
||||||
|
if (CollUtil.isEmpty(userRoleEntities)) {
|
||||||
|
userRoleDomainService.addUserRole(userRoleDo);
|
||||||
|
log.info("成功分配车队长角色给用户 - 角色ID: {}, 角色名称: {}", roleEntity.getRoleId(), roleEntity.getRoleName());
|
||||||
|
} else {
|
||||||
|
log.info("用户已存在车队长角色,跳过 - 角色ID: {}", roleEntity.getRoleId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("未找到车队长角色 - 组织ID: {}, 角色代码: {}, 请检查该组织下是否配置了该角色", organizationId, RoleEnum.CAPTAIN.getCode());
|
||||||
|
// 不抛出异常,允许继续执行,因为角色可能在其他地方分配
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@NeedSetValueField
|
@NeedSetValueField
|
||||||
public Boolean editWeb(MotorcadeDO motorcadeDo) {
|
public Boolean editWeb(MotorcadeDO motorcadeDo) {
|
||||||
@@ -1166,7 +1429,29 @@ public class MotorcadeApplicationService {
|
|||||||
return motorcadeDomainService.queryList(motorcadeDo);
|
return motorcadeDomainService.queryList(motorcadeDo);
|
||||||
}
|
}
|
||||||
public List<MotorcadePo> queryNonePagingList() {
|
public List<MotorcadePo> queryNonePagingList() {
|
||||||
return motorcadeDomainService.queryNonePagingList();
|
// 获取当前登录用户的组织信息,用于数据权限过滤
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long organizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (organizationId != null && organizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据,传递 null 表示不限制
|
||||||
|
log.info("查询车队列表(不分页) - 南光组织,查询所有组织的数据");
|
||||||
|
return motorcadeDomainService.queryNonePagingList(null, null);
|
||||||
|
} else {
|
||||||
|
// 其他组织:只能查询自己组织的数据
|
||||||
|
if (organizationId != null) {
|
||||||
|
log.info("查询车队列表(不分页) - 其他组织,查询组织ID: {}", organizationId);
|
||||||
|
return motorcadeDomainService.queryNonePagingList(organizationId, topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.warn("查询车队列表(不分页) - 未获取到登录用户信息或组织ID,返回空列表");
|
||||||
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -146,6 +146,10 @@ public class OpenUserApplicationService {
|
|||||||
userDriverDO.setUserId(userPo.getUserId());
|
userDriverDO.setUserId(userPo.getUserId());
|
||||||
userDriverDO.setDriverEnterpriseCode(openDriverDto.getDriverEnterpriseCode());
|
userDriverDO.setDriverEnterpriseCode(openDriverDto.getDriverEnterpriseCode());
|
||||||
userDriverDO.setDataSources(openDriverDto.getDataSources());
|
userDriverDO.setDataSources(openDriverDto.getDataSources());
|
||||||
|
// 设置组织信息
|
||||||
|
userDriverDO.setOrganizationId(sysTenantsPo.getOrganizationId());
|
||||||
|
userDriverDO.setTopOrganizationId(sysTenantsPo.getTopOrganizationId());
|
||||||
|
userDriverDO.setOrganizationName(sysTenantsPo.getOrganizationName());
|
||||||
userDriverDomainService.saveUserDriverByOpen(userDriverDO);
|
userDriverDomainService.saveUserDriverByOpen(userDriverDO);
|
||||||
|
|
||||||
//处理车队数据
|
//处理车队数据
|
||||||
|
|||||||
+185
-8
@@ -83,21 +83,77 @@ public class RoleApplicationService {
|
|||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
}
|
}
|
||||||
UserPo userPo = loginUser.getUserPo();
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = roleDo.getOrganizationId();
|
||||||
|
|
||||||
|
// 获取登录用户信息
|
||||||
|
Long loginUserOrganizationId = null;
|
||||||
|
Long topOrganizationId = null;
|
||||||
|
if (userPo != null) {
|
||||||
|
loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
}
|
||||||
|
|
||||||
if (userPo.getUserAccountType() != null && userPo.getUserAccountType() == 5){
|
if (userPo.getUserAccountType() != null && userPo.getUserAccountType() == 5){
|
||||||
roleDo.setCreateBy(userPo.getCreateBy());
|
roleDo.setCreateBy(userPo.getCreateBy());
|
||||||
}else {
|
}else {
|
||||||
UserDataPermissionQueryDTO userDataPermissionQueryDTO = new UserDataPermissionQueryDTO();
|
UserDataPermissionQueryDTO userDataPermissionQueryDTO = new UserDataPermissionQueryDTO();
|
||||||
userDataPermissionQueryDTO.setPermissionMenuId(roleDo.getPermissionMenuId());
|
userDataPermissionQueryDTO.setPermissionMenuId(roleDo.getPermissionMenuId());
|
||||||
userDataPermissionQueryDTO = userDataPermissionApplicationService.getUserDataPermissionQueryDTO(userDataPermissionQueryDTO);
|
userDataPermissionQueryDTO = userDataPermissionApplicationService.getUserDataPermissionQueryDTO(userDataPermissionQueryDTO);
|
||||||
|
|
||||||
|
// 在复制属性之前,先保存前端传递的 organizationId(如果存在)
|
||||||
|
// 因为 BeanUtils.copyProperties 可能会覆盖掉前端传递的值
|
||||||
|
Long savedFrontendOrganizationId = frontendOrganizationId;
|
||||||
|
|
||||||
BeanUtils.copyProperties(userDataPermissionQueryDTO, roleDo, IgnoreNullUtil.getNullPropertyNames(userDataPermissionQueryDTO));
|
BeanUtils.copyProperties(userDataPermissionQueryDTO, roleDo, IgnoreNullUtil.getNullPropertyNames(userDataPermissionQueryDTO));
|
||||||
UserPo loginUserPo = loginUser.getUserPo();
|
UserPo loginUserPo = loginUser.getUserPo();
|
||||||
if (ObjectUtil.isNull(roleDo.getOrganizationId())) {
|
|
||||||
roleDo.setOrganizationId(loginUserPo.getOrganizationId());
|
// 重新获取前端传递的 organizationId(优先使用前端传递的值)
|
||||||
|
// 对于南光组织,如果前端传递了 organizationId,必须使用前端传递的值
|
||||||
|
Long currentFrontendOrganizationId = savedFrontendOrganizationId != null ? savedFrontendOrganizationId : roleDo.getOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:查询权限根据 organizationId 来设置,与其他模块保持一致
|
||||||
|
// organizationId等于2827时,为南光组织,查所有;其他组织查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId(包括2827),使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (currentFrontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||||
|
roleDo.setOrganizationId(currentFrontendOrganizationId);
|
||||||
|
roleDo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
roleDo.setOrganizationId(null);
|
||||||
|
roleDo.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
if (!Strings.isNullOrEmpty(loginUserPo.getRoleCode()) && RoleEnum.SUPER_ADMIN.getCode().equals(loginUserPo.getRoleCode())) {
|
if (!Strings.isNullOrEmpty(loginUserPo.getRoleCode()) && RoleEnum.SUPER_ADMIN.getCode().equals(loginUserPo.getRoleCode())) {
|
||||||
//角色等级:0-无状态,1-内置角色,2-组织角色
|
//角色等级:0-无状态,1-内置角色,2-组织角色
|
||||||
roleDo.setRoleGrade(1);
|
roleDo.setRoleGrade(1);
|
||||||
|
} else {
|
||||||
|
roleDo.setRoleGrade(2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||||
|
if (currentFrontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!currentFrontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("角色查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
currentFrontendOrganizationId, loginUserOrganizationId);
|
||||||
|
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
roleDo.setOrganizationId(currentFrontendOrganizationId);
|
||||||
|
}
|
||||||
|
roleDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
roleDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
roleDo.setRoleGrade(2);
|
roleDo.setRoleGrade(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,8 +200,39 @@ public class RoleApplicationService {
|
|||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
}
|
}
|
||||||
UserPo loginUserPo = loginUser.getUserPo();
|
UserPo loginUserPo = loginUser.getUserPo();
|
||||||
if (ObjectUtil.isNull(roleDo.getOrganizationId())) {
|
|
||||||
roleDo.setOrganizationId(loginUserPo.getOrganizationId());
|
// 保存前端传递的 organizationId
|
||||||
|
Long frontendOrganizationId = roleDo.getOrganizationId();
|
||||||
|
Long loginUserOrganizationId = loginUserPo.getOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:查询权限根据 organizationId 来设置,与其他模块保持一致
|
||||||
|
// organizationId等于2827时,为南光组织,查所有;其他组织查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId 且不等于 2827,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId 或传递的是 2827,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null && !frontendOrganizationId.equals(2827L)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,使用前端传递的值进行过滤
|
||||||
|
roleDo.setOrganizationId(frontendOrganizationId);
|
||||||
|
roleDo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId 或传递的是 2827,清空组织过滤条件,查询所有组织的数据
|
||||||
|
roleDo.setOrganizationId(null);
|
||||||
|
roleDo.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
if (ObjectUtil.isNull(frontendOrganizationId)) {
|
||||||
|
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("角色查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return roleDomainService.selectList(roleDo);
|
return roleDomainService.selectList(roleDo);
|
||||||
}
|
}
|
||||||
@@ -226,10 +313,36 @@ public class RoleApplicationService {
|
|||||||
}
|
}
|
||||||
UserPo loginUserPo = loginUser.getUserPo();
|
UserPo loginUserPo = loginUser.getUserPo();
|
||||||
|
|
||||||
//校验组织ID是否存在
|
// 数据隔离:校验组织ID和权限,与其他模块保持一致
|
||||||
if(ObjectUtil.isNull(roleDo.getOrganizationId())){
|
Long frontendOrganizationId = roleDo.getOrganizationId();
|
||||||
roleDo.setOrganizationId(loginUserPo.getOrganizationId());
|
Long loginUserOrganizationId = loginUserPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = loginUserPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 判断是否为南光组织:topOrganizationId == null 时为顶级组织(南光组织)
|
||||||
|
// 与其他模块保持一致(VerificationApplicationService、TmsReceiptApplicationService等)
|
||||||
|
boolean isNanguangOrg = (topOrganizationId == null);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNull(frontendOrganizationId)) {
|
||||||
|
// 如果前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 如果前端传递了 organizationId,需要进行数据权限校验
|
||||||
|
if (isNanguangOrg) {
|
||||||
|
// 南光组织:可以为任何组织创建角色,使用前端传递的 organizationId
|
||||||
|
roleDo.setOrganizationId(frontendOrganizationId);
|
||||||
|
log.info("南光组织创建角色 - 目标组织ID: {}", frontendOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 其他组织:只能为自己组织创建角色,不能为其他组织创建角色
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
log.warn("非南光组织尝试为其他组织创建角色 - 登录用户组织ID: {}, 尝试创建的组织ID: {}",
|
||||||
|
loginUserOrganizationId, frontendOrganizationId);
|
||||||
|
throw new ServiceException("无权限为其他组织创建角色,只能为本组织创建角色");
|
||||||
|
}
|
||||||
|
// 使用当前登录用户的组织ID
|
||||||
|
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjectUtil.isNotNull(roleDo.getRoleId())) {
|
if (ObjectUtil.isNotNull(roleDo.getRoleId())) {
|
||||||
RolePO rolePO = roleDomainService.selectByRoleId(roleDo.getRoleId());
|
RolePO rolePO = roleDomainService.selectByRoleId(roleDo.getRoleId());
|
||||||
if (rolePO == null) {
|
if (rolePO == null) {
|
||||||
@@ -254,7 +367,58 @@ public class RoleApplicationService {
|
|||||||
if (roleEntity != null){
|
if (roleEntity != null){
|
||||||
throw new ServiceException("角色编码重复");
|
throw new ServiceException("角色编码重复");
|
||||||
}
|
}
|
||||||
roleDo.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
// 设置组织信息:保留传入的 organizationId,如果为 null 则使用当前登录用户的组织ID
|
||||||
|
// 注意:不能强制覆盖传入的 organizationId,否则会导致角色保存到错误的组织下
|
||||||
|
if (roleDo.getOrganizationId() == null) {
|
||||||
|
roleDo.setOrganizationId(loginUserPo.getOrganizationId());
|
||||||
|
roleDo.setOrganizationName(loginUserPo.getOrganizationName());
|
||||||
|
roleDo.setTopOrganizationId(loginUserPo.getTopOrganizationId());
|
||||||
|
} else {
|
||||||
|
// 如果传入了 organizationId,需要根据该 organizationId 查询对应的 organizationName
|
||||||
|
// 如果 organizationName 为空,尝试通过 Feign 查询组织信息
|
||||||
|
if (roleDo.getOrganizationName() == null || roleDo.getOrganizationName().isEmpty()) {
|
||||||
|
try {
|
||||||
|
AjaxResult orgInfo = organizationServiceFeign.getInfo(roleDo.getOrganizationId());
|
||||||
|
if (orgInfo != null && "200".equals(String.valueOf(orgInfo.get("code")))) {
|
||||||
|
JSONObject data = (JSONObject) orgInfo.get("data");
|
||||||
|
if (data != null && data.containsKey("organizationName")) {
|
||||||
|
roleDo.setOrganizationName(data.getString("organizationName"));
|
||||||
|
log.info("通过 ProductServiceFeign 获取到组织名称: {}", roleDo.getOrganizationName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果查询失败,使用当前登录用户的组织名称作为默认值
|
||||||
|
if (roleDo.getOrganizationName() == null || roleDo.getOrganizationName().isEmpty()) {
|
||||||
|
roleDo.setOrganizationName(loginUserPo.getOrganizationName());
|
||||||
|
log.warn("无法通过 organizationId {} 获取组织名称,使用当前登录用户的组织名称作为默认值", roleDo.getOrganizationId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("通过 ProductServiceFeign 获取组织名称失败: {},使用当前登录用户的组织名称作为默认值", e.getMessage());
|
||||||
|
roleDo.setOrganizationName(loginUserPo.getOrganizationName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果 topOrganizationId 为空,尝试从组织信息中获取,否则使用当前登录用户的顶级组织ID
|
||||||
|
if (roleDo.getTopOrganizationId() == null) {
|
||||||
|
try {
|
||||||
|
AjaxResult orgInfo = organizationServiceFeign.getInfo(roleDo.getOrganizationId());
|
||||||
|
if (orgInfo != null && "200".equals(String.valueOf(orgInfo.get("code")))) {
|
||||||
|
JSONObject data = (JSONObject) orgInfo.get("data");
|
||||||
|
if (data != null && data.containsKey("topOrganizationId")) {
|
||||||
|
Object topOrgId = data.get("topOrganizationId");
|
||||||
|
if (topOrgId != null) {
|
||||||
|
roleDo.setTopOrganizationId(Long.parseLong(topOrgId.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果查询失败,使用当前登录用户的顶级组织ID作为默认值
|
||||||
|
if (roleDo.getTopOrganizationId() == null) {
|
||||||
|
roleDo.setTopOrganizationId(loginUserPo.getTopOrganizationId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("通过 ProductServiceFeign 获取顶级组织ID失败: {},使用当前登录用户的顶级组织ID作为默认值", e.getMessage());
|
||||||
|
roleDo.setTopOrganizationId(loginUserPo.getTopOrganizationId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
roleDo.setCreateBy(loginUserPo.getUserId());
|
roleDo.setCreateBy(loginUserPo.getUserId());
|
||||||
roleDo.setCreateByName(loginUserPo.getUserName());
|
roleDo.setCreateByName(loginUserPo.getUserName());
|
||||||
roleDo.setCreateTime(new Date());
|
roleDo.setCreateTime(new Date());
|
||||||
@@ -263,6 +427,19 @@ public class RoleApplicationService {
|
|||||||
roleDo.setUpdateTime(new Date());
|
roleDo.setUpdateTime(new Date());
|
||||||
//删除标记:0-无状态,1-正常,2-已删除
|
//删除标记:0-无状态,1-正常,2-已删除
|
||||||
roleDo.setDelFlag(1);
|
roleDo.setDelFlag(1);
|
||||||
|
|
||||||
|
// 添加调试日志,确认保存的角色信息
|
||||||
|
log.info("新增角色 - 组织ID: {}, 组织名称: {}, 角色代码: {}, 角色名称: {}, 顶级组织ID: {}",
|
||||||
|
roleDo.getOrganizationId(), roleDo.getOrganizationName(), roleDo.getRoleCode(),
|
||||||
|
roleDo.getRoleName(), roleDo.getTopOrganizationId());
|
||||||
|
|
||||||
|
// 确保 organizationName 不为空,否则查询时会查不到
|
||||||
|
if (roleDo.getOrganizationName() == null || roleDo.getOrganizationName().isEmpty()) {
|
||||||
|
log.error("新增角色失败 - organizationName 为空!组织ID: {}, 角色代码: {}",
|
||||||
|
roleDo.getOrganizationId(), roleDo.getRoleCode());
|
||||||
|
throw new ServiceException("组织名称不能为空,请检查组织信息是否正确");
|
||||||
|
}
|
||||||
|
|
||||||
int i = roleDomainService.addRole(roleDo);
|
int i = roleDomainService.addRole(roleDo);
|
||||||
Long roleId = roleDo.getRoleId();
|
Long roleId = roleDo.getRoleId();
|
||||||
//复制之前角色的菜单
|
//复制之前角色的菜单
|
||||||
|
|||||||
+120
-11
@@ -330,17 +330,82 @@ public class UserApplicationService {
|
|||||||
* @Date 2023/1/12 14:58
|
* @Date 2023/1/12 14:58
|
||||||
*/
|
*/
|
||||||
public List<UserPo> staffList(UserDO userDo) {
|
public List<UserPo> staffList(UserDO userDo) {
|
||||||
|
// 首先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = userDo.getOrganizationId();
|
||||||
|
|
||||||
//获取当前登陆人
|
//获取当前登陆人
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
UserPo userPo = loginUser.getUserPo();
|
UserPo userPo = loginUser.getUserPo();
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
}
|
}
|
||||||
if (userPo.getRoleCode().contains(RoleEnum.PLAT_ADMIN.getCode()) && ObjectUtil.equal(userPo.getOrganizationId(),userPo.getTopOrganizationId())){
|
|
||||||
userDo.setTopOrganizationId(userPo.getTopOrganizationId());
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
}else {
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
userDo.setOrganizationId(userPo.getOrganizationId());
|
|
||||||
|
// 数据权限:查询权限根据 organizationId 来设置
|
||||||
|
// 当 organizationId 是 2827 时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤(包括2827)
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
userDo.setOrganizationId(frontendOrganizationId);
|
||||||
|
userDo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
// 但如果用户是平台管理员且 organizationId 等于 topOrganizationId,使用 topOrganizationId
|
||||||
|
if (userPo.getRoleCode() != null && userPo.getRoleCode().contains(RoleEnum.PLAT_ADMIN.getCode())
|
||||||
|
&& ObjectUtil.equal(loginUserOrganizationId, topOrganizationId)) {
|
||||||
|
userDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
userDo.setOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
userDo.setOrganizationId(null);
|
||||||
|
userDo.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织(包括南光)的数据
|
||||||
|
// 如果其他组织尝试查询南光(organizationId=2827)的数据,返回空数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (frontendOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织尝试查询南光的数据,设置一个不存在的 organizationId,返回空数据
|
||||||
|
userDo.setOrganizationId(-1L);
|
||||||
|
userDo.setTopOrganizationId(null);
|
||||||
|
} else if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
userDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
userDo.setOrganizationId(frontendOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
// 如果用户是平台管理员且 organizationId 等于 topOrganizationId,使用 topOrganizationId
|
||||||
|
if (userPo.getRoleCode() != null && userPo.getRoleCode().contains(RoleEnum.PLAT_ADMIN.getCode())
|
||||||
|
&& ObjectUtil.equal(loginUserOrganizationId, topOrganizationId)) {
|
||||||
|
userDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
userDo.setOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
userDo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return userDomainService.selectList(userDo);
|
return userDomainService.selectList(userDo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1084,6 +1149,19 @@ public class UserApplicationService {
|
|||||||
if (ObjectUtil.isNull(userDO.getOrganizationId())) {
|
if (ObjectUtil.isNull(userDO.getOrganizationId())) {
|
||||||
userDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
userDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
userDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
userDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||||
|
} else {
|
||||||
|
// 如果前端传递了 organizationId,根据 organizationId 查询组织信息,获取正确的组织名称
|
||||||
|
AjaxResult orgInfoResult = productServiceFeign.getInfo(userDO.getOrganizationId());
|
||||||
|
String orgInfoCode = orgInfoResult.get("code").toString();
|
||||||
|
if ("200".equals(orgInfoCode)) {
|
||||||
|
Object orgData = orgInfoResult.get("data");
|
||||||
|
if (ObjectUtil.isNotNull(orgData)) {
|
||||||
|
OrganizationPo organizationPo = BeanUtil.toBean(orgData, OrganizationPo.class);
|
||||||
|
if (ObjectUtil.isNotNull(organizationPo)) {
|
||||||
|
userDO.setOrganizationName(organizationPo.getOrganizationName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UserPo userPo = new UserPo();
|
UserPo userPo = new UserPo();
|
||||||
//先根据组织ID获取一级组织
|
//先根据组织ID获取一级组织
|
||||||
@@ -1151,7 +1229,15 @@ public class UserApplicationService {
|
|||||||
}
|
}
|
||||||
BeanUtils.copyProperties(userEntity, userPo);
|
BeanUtils.copyProperties(userEntity, userPo);
|
||||||
//同步网货平台员工信息
|
//同步网货平台员工信息
|
||||||
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
try {
|
||||||
|
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 同步网货失败时,记录日志但不影响用户保存
|
||||||
|
// 避免同步失败导致整个事务回滚,用户数据无法保存
|
||||||
|
log.warn("同步网货平台员工信息失败,但不影响用户保存: {}", e.getMessage());
|
||||||
|
// 如果业务要求必须同步成功,可以取消下面的注释,让异常抛出
|
||||||
|
// throw e;
|
||||||
|
}
|
||||||
return userPo;
|
return userPo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1249,7 +1335,12 @@ public class UserApplicationService {
|
|||||||
}
|
}
|
||||||
BeanUtils.copyProperties(userEntity, userPo);
|
BeanUtils.copyProperties(userEntity, userPo);
|
||||||
//同步网货平台员工信息
|
//同步网货平台员工信息
|
||||||
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
try {
|
||||||
|
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 同步网货失败时,记录日志但不影响用户保存
|
||||||
|
log.warn("同步网货平台员工信息失败,但不影响用户保存: {}", e.getMessage());
|
||||||
|
}
|
||||||
return userPo;
|
return userPo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1342,7 +1433,12 @@ public class UserApplicationService {
|
|||||||
}
|
}
|
||||||
BeanUtils.copyProperties(userEntity, userPo);
|
BeanUtils.copyProperties(userEntity, userPo);
|
||||||
//同步网货平台员工信息
|
//同步网货平台员工信息
|
||||||
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
try {
|
||||||
|
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 同步网货失败时,记录日志但不影响用户保存
|
||||||
|
log.warn("同步网货平台员工信息失败,但不影响用户保存: {}", e.getMessage());
|
||||||
|
}
|
||||||
return userPo;
|
return userPo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4823,12 +4919,25 @@ public class UserApplicationService {
|
|||||||
if (Objects.isNull(loginUser)){
|
if (Objects.isNull(loginUser)){
|
||||||
throw new ServiceException("当前用户不存在!");
|
throw new ServiceException("当前用户不存在!");
|
||||||
}
|
}
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
Long filterOrganizationId = null;
|
||||||
Long userId = null;
|
Long userId = null;
|
||||||
if(loginUser.getUserPo().getBusinessType()==1||loginUser.getUserPo().getBusinessType()==3||loginUser.getUserPo().getUserAccountType()==5){
|
|
||||||
userId = loginUser.getUserid();
|
// 数据隔离:根据 organizationId 字段来实现
|
||||||
|
// 如果当前登录用户的organizationId为2827,可查询全部组织数据;其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织:查询所有组织的数据,不设置 organizationId 和 userId 过滤条件
|
||||||
|
filterOrganizationId = null;
|
||||||
|
userId = null;
|
||||||
|
} else {
|
||||||
|
// 其他组织:只查询自己组织的数据
|
||||||
|
filterOrganizationId = loginUserOrganizationId;
|
||||||
|
// 如果当前登录用户是货主或企业用户,只查询当前登录用户的信息
|
||||||
|
if(loginUser.getUserPo().getBusinessType()==1||loginUser.getUserPo().getBusinessType()==3||loginUser.getUserPo().getUserAccountType()==5){
|
||||||
|
userId = loginUser.getUserid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return userDomainService.findAllShipperInfo(userId,topOrganizationId);
|
return userDomainService.findAllShipperInfo(userId, filterOrganizationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryAllShipperInfoVo convertToVo(UserEntity userEntity) {
|
private QueryAllShipperInfoVo convertToVo(UserEntity userEntity) {
|
||||||
|
|||||||
+116
@@ -323,6 +323,14 @@ public class UserDriverApplicationService {
|
|||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
if (userPo != null) {
|
||||||
|
userDriverDO.setOrganizationId(userPo.getOrganizationId());
|
||||||
|
userDriverDO.setOrganizationName(userPo.getOrganizationName());
|
||||||
|
userDriverDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||||
|
}
|
||||||
|
|
||||||
if(userDriverDO.getUserDriverType()==1&&StringUtils.isBlank(userDriverDO.getDepartmentId())){
|
if(userDriverDO.getUserDriverType()==1&&StringUtils.isBlank(userDriverDO.getDepartmentId())){
|
||||||
throw new ServiceException("请维护司机部门信息");
|
throw new ServiceException("请维护司机部门信息");
|
||||||
}
|
}
|
||||||
@@ -345,6 +353,9 @@ public class UserDriverApplicationService {
|
|||||||
throw new ServiceException("用户ID未设置,无法继续司机认证流程");
|
throw new ServiceException("用户ID未设置,无法继续司机认证流程");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增承运人时,使用当前登录账号的用户角色
|
||||||
|
assignLoginUserRolesToDriver(userDriverDO.getUserId(), loginUser);
|
||||||
|
|
||||||
// 新增的自有司机,默认审核通过
|
// 新增的自有司机,默认审核通过
|
||||||
if (userDriverDO.getUserDriverType().equals(UserDriverConstants.OWN_DIVER)){
|
if (userDriverDO.getUserDriverType().equals(UserDriverConstants.OWN_DIVER)){
|
||||||
userDriverDO.setDriverFill(UserDriverConstants.AUTH_STATUS_APPROVED);
|
userDriverDO.setDriverFill(UserDriverConstants.AUTH_STATUS_APPROVED);
|
||||||
@@ -580,6 +591,111 @@ public class UserDriverApplicationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将"个人司机"角色分配给新创建的承运人用户
|
||||||
|
* 优先从当前登录用户的角色中获取"个人司机"角色,如果找不到,再根据组织ID查询
|
||||||
|
* @param driverUserId 承运人用户ID
|
||||||
|
* @param loginUser 当前登录用户
|
||||||
|
*/
|
||||||
|
private void assignLoginUserRolesToDriver(Long driverUserId, LoginUser loginUser) {
|
||||||
|
if (driverUserId == null || loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("分配角色失败 - 承运人用户ID或登录用户信息为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("新增承运人 - 分配个人司机角色,承运人用户ID: {}", driverUserId);
|
||||||
|
|
||||||
|
Long loginUserId = loginUser.getUserPo().getUserId();
|
||||||
|
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 优先从当前登录用户的角色中查找"个人司机"角色
|
||||||
|
List<UserRoleMenuPO> loginUserRoleList = userRoleDomainService.selectRolesByUserId(loginUserId);
|
||||||
|
RoleEntity roleEntity = null;
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(loginUserRoleList)) {
|
||||||
|
log.info("当前登录用户共有 {} 个角色,查找个人司机角色", loginUserRoleList.size());
|
||||||
|
for (UserRoleMenuPO loginUserRole : loginUserRoleList) {
|
||||||
|
if (RoleEnum.DRIVER.getCode().equals(loginUserRole.getRoleCode())) {
|
||||||
|
// 找到"个人司机"角色,使用当前登录用户的角色ID
|
||||||
|
log.info("从当前登录用户的角色中找到个人司机角色 - 角色ID: {}, 角色代码: {}", loginUserRole.getRoleId(), loginUserRole.getRoleCode());
|
||||||
|
roleEntity = new RoleEntity();
|
||||||
|
roleEntity.setRoleId(loginUserRole.getRoleId());
|
||||||
|
roleEntity.setRoleCode(loginUserRole.getRoleCode());
|
||||||
|
roleEntity.setRoleName(loginUserRole.getRoleName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前登录用户没有"个人司机"角色,根据组织ID查询
|
||||||
|
if (ObjectUtil.isNull(roleEntity)) {
|
||||||
|
if (organizationId == null) {
|
||||||
|
log.warn("当前登录用户的组织ID为空,无法查询个人司机角色");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("当前登录用户没有个人司机角色,根据组织ID查询 - 组织ID: {}, 角色代码: {}", organizationId, RoleEnum.DRIVER.getCode());
|
||||||
|
|
||||||
|
// 查询"个人司机"角色
|
||||||
|
RoleDo roleDo = new RoleDo();
|
||||||
|
roleDo.setRoleCode(RoleEnum.DRIVER.getCode());
|
||||||
|
roleDo.setOrganizationId(organizationId);
|
||||||
|
|
||||||
|
roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
|
||||||
|
|
||||||
|
// 如果当前组织查询不到,尝试回退查询(不检查 organization_name IS NOT NULL)
|
||||||
|
if (ObjectUtil.isNull(roleEntity)) {
|
||||||
|
log.warn("使用 organization_name IS NOT NULL 条件查询不到角色,尝试回退查询(不检查 organization_name)- 组织ID: {}, 角色代码: {}", organizationId, RoleEnum.DRIVER.getCode());
|
||||||
|
com.mhd.common.core.domain.po.RolePO rolePO = roleDomainService.selectByRoleCodeAndOrganizationId(RoleEnum.DRIVER.getCode(), organizationId);
|
||||||
|
if (ObjectUtil.isNotNull(rolePO)) {
|
||||||
|
// 将 RolePO 转换为 RoleEntity
|
||||||
|
roleEntity = new RoleEntity();
|
||||||
|
roleEntity.setRoleId(rolePO.getRoleId());
|
||||||
|
roleEntity.setRoleCode(rolePO.getRoleCode());
|
||||||
|
roleEntity.setRoleName(rolePO.getRoleName());
|
||||||
|
roleEntity.setRoleRemark(rolePO.getRoleRemark());
|
||||||
|
roleEntity.setRoleDataScope(rolePO.getRoleDataScope());
|
||||||
|
roleEntity.setRoleStatus(rolePO.getRoleStatus());
|
||||||
|
roleEntity.setRoleType(rolePO.getRoleType());
|
||||||
|
roleEntity.setOrganizationId(rolePO.getOrganizationId());
|
||||||
|
roleEntity.setOrganizationName(rolePO.getOrganizationName());
|
||||||
|
roleEntity.setTopOrganizationId(rolePO.getTopOrganizationId());
|
||||||
|
log.info("回退查询成功找到角色 - 角色ID: {}, 角色名称: {}, 组织名称: {}", roleEntity.getRoleId(), roleEntity.getRoleName(), roleEntity.getOrganizationName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果还是查询不到,尝试使用顶级组织ID查询
|
||||||
|
if (ObjectUtil.isNull(roleEntity)) {
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
if (topOrganizationId != null && topOrganizationId.equals(organizationId)) {
|
||||||
|
log.info("当前组织查询不到角色,尝试使用顶级组织ID查询 - 顶级组织ID: {}, 角色代码: {}", topOrganizationId, RoleEnum.DRIVER.getCode());
|
||||||
|
roleDo.setOrganizationId(null);
|
||||||
|
roleDo.setTopOrganizationId(topOrganizationId);
|
||||||
|
roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(roleEntity)) {
|
||||||
|
log.info("找到个人司机角色 - 角色ID: {}, 角色名称: {}", roleEntity.getRoleId(), roleEntity.getRoleName());
|
||||||
|
UserRoleDo userRoleDo = new UserRoleDo();
|
||||||
|
userRoleDo.setUserId(driverUserId);
|
||||||
|
userRoleDo.setRoleId(roleEntity.getRoleId());
|
||||||
|
|
||||||
|
// 判断是否已存在相应角色
|
||||||
|
List<UserRoleEntity> userRoleEntities = userRoleDomainService.selectList(userRoleDo);
|
||||||
|
if (CollUtil.isEmpty(userRoleEntities)) {
|
||||||
|
userRoleDomainService.addUserRole(userRoleDo);
|
||||||
|
log.info("成功分配个人司机角色给承运人用户 - 角色ID: {}, 角色名称: {}", roleEntity.getRoleId(), roleEntity.getRoleName());
|
||||||
|
} else {
|
||||||
|
log.info("承运人用户已存在个人司机角色,跳过 - 角色ID: {}", roleEntity.getRoleId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("未找到个人司机角色 - 组织ID: {}, 角色代码: {}, 请检查该组织下是否配置了该角色", organizationId, RoleEnum.DRIVER.getCode());
|
||||||
|
// 不抛出异常,允许继续执行,因为角色可能在其他地方分配
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 托运人待审核推送
|
* 托运人待审核推送
|
||||||
*/
|
*/
|
||||||
|
|||||||
+149
-21
@@ -29,6 +29,7 @@ import com.mhd.system.api.service.webSocket.AsyncWebSocketApplicationService;
|
|||||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||||
import com.mhd.user.domain.roleAggregate.service.RoleDomainService;
|
import com.mhd.user.domain.roleAggregate.service.RoleDomainService;
|
||||||
|
import com.mhd.common.core.domain.po.RolePO;
|
||||||
import com.mhd.user.domain.userAggregate.entity.UserRoleEntity;
|
import com.mhd.user.domain.userAggregate.entity.UserRoleEntity;
|
||||||
import com.mhd.user.domain.userAggregate.entity.UserShipperEntity;
|
import com.mhd.user.domain.userAggregate.entity.UserShipperEntity;
|
||||||
import com.mhd.user.domain.userAggregate.event.ShipperEventPublisher;
|
import com.mhd.user.domain.userAggregate.event.ShipperEventPublisher;
|
||||||
@@ -118,17 +119,80 @@ public class UserShipperApplicationService {
|
|||||||
*/
|
*/
|
||||||
@NeedSetValueMethod
|
@NeedSetValueMethod
|
||||||
public List<UserShipperPo> userShipperList(UserShipperDO userShipperDO) {
|
public List<UserShipperPo> userShipperList(UserShipperDO userShipperDO) {
|
||||||
// userShipperDO.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
|
// 获取登录人信息
|
||||||
List<UserShipperPo> userShipperList=userShipperDomainService.userShipperList(userShipperDO);
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
for(UserShipperPo userShipperPo:userShipperList){
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
R<TmsShipper> tmsShipper=wlhyServiceFeign.queryBySzwlUserId(userShipperPo.getUserId());
|
log.warn("托运人列表查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
List<UserShipperPo> userShipperList = userShipperDomainService.userShipperList(userShipperDO);
|
||||||
|
return processShipperList(userShipperList);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = userShipperDO.getOrganizationId();
|
||||||
|
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
userShipperDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
userShipperDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
userShipperDO.setOrganizationId(null);
|
||||||
|
userShipperDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置 organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("托运人列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
userShipperDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userShipperDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userShipperDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserShipperPo> userShipperList = userShipperDomainService.userShipperList(userShipperDO);
|
||||||
|
return processShipperList(userShipperList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理托运人列表,填充网货平台数据
|
||||||
|
*/
|
||||||
|
private List<UserShipperPo> processShipperList(List<UserShipperPo> userShipperList) {
|
||||||
|
for(UserShipperPo userShipperPo : userShipperList){
|
||||||
|
R<TmsShipper> tmsShipper = wlhyServiceFeign.queryBySzwlUserId(userShipperPo.getUserId());
|
||||||
if (tmsShipper.getCode() == R.SUCCESS) {
|
if (tmsShipper.getCode() == R.SUCCESS) {
|
||||||
if(ObjectUtil.isNotNull(tmsShipper.getData())){
|
if(ObjectUtil.isNotNull(tmsShipper.getData())){
|
||||||
userShipperPo.setAuthorizedQuota(tmsShipper.getData().getCreditLine());
|
userShipperPo.setAuthorizedQuota(tmsShipper.getData().getCreditLine());
|
||||||
userShipperPo.setSettlementDay(tmsShipper.getData().getSettlementInterval());
|
userShipperPo.setSettlementDay(tmsShipper.getData().getSettlementInterval());
|
||||||
userShipperPo.setAuthorizedUsedAmount(tmsShipper.getData().getUsedQuota());
|
userShipperPo.setAuthorizedUsedAmount(tmsShipper.getData().getUsedQuota());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return userShipperList;
|
return userShipperList;
|
||||||
@@ -154,6 +218,13 @@ public class UserShipperApplicationService {
|
|||||||
if (ObjectUtil.isNull(loginUser)) {
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
throw new DigitalLogisticsException(UserError.USER_NULL);
|
throw new DigitalLogisticsException(UserError.USER_NULL);
|
||||||
}
|
}
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
if (userPo != null) {
|
||||||
|
userShipperDO.setOrganizationId(userPo.getOrganizationId());
|
||||||
|
userShipperDO.setOrganizationName(userPo.getOrganizationName());
|
||||||
|
userShipperDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||||
|
}
|
||||||
// 2023年5月22日,改动为个人认证和企业认证分开认证,所以此处需要根据前端认证的角色,给不同的字段赋值
|
// 2023年5月22日,改动为个人认证和企业认证分开认证,所以此处需要根据前端认证的角色,给不同的字段赋值
|
||||||
if (userShipperDO.getShipperType() == null) {
|
if (userShipperDO.getShipperType() == null) {
|
||||||
throw new ServiceException("角色类型不能为空");
|
throw new ServiceException("角色类型不能为空");
|
||||||
@@ -652,28 +723,33 @@ public class UserShipperApplicationService {
|
|||||||
String roleCodes = null;
|
String roleCodes = null;
|
||||||
//实名认证通过此时赋值企业、个人货主角色
|
//实名认证通过此时赋值企业、个人货主角色
|
||||||
if (userShipperDO.getShipperAuthStatus() == 3) {
|
if (userShipperDO.getShipperAuthStatus() == 3) {
|
||||||
RoleDo roleDo = new RoleDo();
|
// 新增委托方时,使用当前登录账号的用户角色
|
||||||
if (userShipperDO.getAuthType() == 1) {
|
Long loginUserId = loginUser.getUserPo().getUserId();
|
||||||
roleDo.setRoleCode(RoleEnum.SHIPPER.getCode());
|
log.info("新增委托方 - 使用当前登录用户的角色,登录用户ID: {}", loginUserId);
|
||||||
} else if (userShipperDO.getAuthType() == 2) {
|
|
||||||
roleDo.setRoleCode(RoleEnum.COMPANY.getCode());
|
// 获取当前登录用户的所有角色
|
||||||
} else {
|
List<UserRoleMenuPO> loginUserRoleList = userRoleDomainService.selectRolesByUserId(loginUserId);
|
||||||
throw new ServiceException("角色未找到");
|
if (CollUtil.isEmpty(loginUserRoleList)) {
|
||||||
|
log.warn("当前登录用户没有角色,登录用户ID: {}", loginUserId);
|
||||||
|
throw new ServiceException("当前登录用户没有角色,无法分配给委托方");
|
||||||
}
|
}
|
||||||
roleDo.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
RoleEntity roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
|
log.info("当前登录用户共有 {} 个角色", loginUserRoleList.size());
|
||||||
if (ObjectUtil.isNotNull(roleEntity)) {
|
|
||||||
|
// 将当前登录用户的所有角色分配给新创建的委托方用户
|
||||||
|
for (UserRoleMenuPO loginUserRole : loginUserRoleList) {
|
||||||
UserRoleDo userRoleDo = new UserRoleDo();
|
UserRoleDo userRoleDo = new UserRoleDo();
|
||||||
userRoleDo.setUserId(userShipperDO.getUserId());
|
userRoleDo.setUserId(userShipperDO.getUserId());
|
||||||
userRoleDo.setRoleId(roleEntity.getRoleId());
|
userRoleDo.setRoleId(loginUserRole.getRoleId());
|
||||||
// userApplicationService.assignUserRoles(userRoleDo);
|
|
||||||
//判断是否已存在相应角色
|
// 判断是否已存在相应角色
|
||||||
List<UserRoleEntity> userRoleEntities = userRoleDomainService.selectList(userRoleDo);
|
List<UserRoleEntity> userRoleEntities = userRoleDomainService.selectList(userRoleDo);
|
||||||
if (CollUtil.isEmpty(userRoleEntities)) {
|
if (CollUtil.isEmpty(userRoleEntities)) {
|
||||||
userRoleDomainService.addUserRole(userRoleDo);
|
userRoleDomainService.addUserRole(userRoleDo);
|
||||||
|
log.info("成功分配角色给委托方用户 - 角色ID: {}, 角色代码: {}", loginUserRole.getRoleId(), loginUserRole.getRoleCode());
|
||||||
|
} else {
|
||||||
|
log.info("委托方用户已存在该角色,跳过 - 角色ID: {}, 角色代码: {}", loginUserRole.getRoleId(), loginUserRole.getRoleCode());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new ServiceException("当前组织无相应角色");
|
|
||||||
}
|
}
|
||||||
//审核通过后,调用用户开通钱包
|
//审核通过后,调用用户开通钱包
|
||||||
AccountCashWalletDto accountCashWalletDto = new AccountCashWalletDto();
|
AccountCashWalletDto accountCashWalletDto = new AccountCashWalletDto();
|
||||||
@@ -773,7 +849,59 @@ public class UserShipperApplicationService {
|
|||||||
*/
|
*/
|
||||||
public Map<String, String> userShipperCount(UserShipperDO userShipperDO) {
|
public Map<String, String> userShipperCount(UserShipperDO userShipperDO) {
|
||||||
Map<String, String> res = new HashMap<>();
|
Map<String, String> res = new HashMap<>();
|
||||||
// userShipperDO.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
|
|
||||||
|
// 获取登录人信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("托运人统计查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
} else {
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = userShipperDO.getOrganizationId();
|
||||||
|
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据 topOrganizationId 来设置查询权限,与其他模块保持一致
|
||||||
|
// topOrganizationId 为 null 时,为顶级组织(南光组织),查所有;其他组织查自己
|
||||||
|
if (topOrganizationId == null) {
|
||||||
|
// 南光组织:可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
userShipperDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
userShipperDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
userShipperDO.setOrganizationId(null);
|
||||||
|
userShipperDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置 organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("托运人统计查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
userShipperDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
userShipperDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
userShipperDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
userShipperDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//先将所有托运人查询出来,然后再进行
|
//先将所有托运人查询出来,然后再进行
|
||||||
List<UserShipperPo> userShipperPoList = userShipperDomainService.userShipperAndRoleList(userShipperDO);
|
List<UserShipperPo> userShipperPoList = userShipperDomainService.userShipperAndRoleList(userShipperDO);
|
||||||
//托运人总数
|
//托运人总数
|
||||||
|
|||||||
+1
-1
@@ -71,5 +71,5 @@ public interface MotorcadeRepositoryInterface extends IService<Motorcade>
|
|||||||
|
|
||||||
List<MotorcadePo> getAllOtherMotorcade(Long userId);
|
List<MotorcadePo> getAllOtherMotorcade(Long userId);
|
||||||
|
|
||||||
List<MotorcadePo> queryNonePagingList(Long organizationId);
|
List<MotorcadePo> queryNonePagingList(Long organizationId, Long topOrganizationId);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ public interface MotorcadeMapper extends BaseMapper<Motorcade>
|
|||||||
*/
|
*/
|
||||||
public List<MotorcadePo> queryList(MotorcadeDO motorcadeDo);
|
public List<MotorcadePo> queryList(MotorcadeDO motorcadeDo);
|
||||||
|
|
||||||
List<MotorcadePo> queryNonePagingList(@Param("organizationId") Long organizationId);
|
List<MotorcadePo> queryNonePagingList(@Param("organizationId") Long organizationId, @Param("topOrganizationId") Long topOrganizationId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询我加入的所以车队id
|
* 查询我加入的所以车队id
|
||||||
|
|||||||
+2
-2
@@ -130,7 +130,7 @@ public class MotorcadeRepositoryImpl extends ServiceImpl<MotorcadeMapper, Motorc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MotorcadePo> queryNonePagingList(Long organizationId) {
|
public List<MotorcadePo> queryNonePagingList(Long organizationId, Long topOrganizationId) {
|
||||||
return motorcadeMapper.queryNonePagingList(organizationId);
|
return motorcadeMapper.queryNonePagingList(organizationId, topOrganizationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-6
@@ -182,11 +182,7 @@ public class MotorcadeDomainService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<MotorcadePo> queryNonePagingList() {
|
public List<MotorcadePo> queryNonePagingList(Long organizationId, Long topOrganizationId) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
return motorcadeInterface.queryNonePagingList(organizationId, topOrganizationId);
|
||||||
if (loginUser != null && loginUser.getUserPo() != null &&loginUser.getUserPo().getTopOrganizationId()!= null){
|
|
||||||
return motorcadeInterface.queryNonePagingList(loginUser.getUserPo().getTopOrganizationId());
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public class RoleEntity extends BaseVOEntity {
|
|||||||
private Integer roleType;
|
private Integer roleType;
|
||||||
@ApiModelProperty(name = "组织表ID")
|
@ApiModelProperty(name = "组织表ID")
|
||||||
private Long organizationId;
|
private Long organizationId;
|
||||||
|
@ApiModelProperty(name = "组织名称")
|
||||||
|
private String organizationName;
|
||||||
|
@ApiModelProperty(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
@ApiModelProperty(name = "职务/角色权限字符,控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)")
|
@ApiModelProperty(name = "职务/角色权限字符,控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)")
|
||||||
private String roleCode;
|
private String roleCode;
|
||||||
@ApiModelProperty(name = "职务/角色名称")
|
@ApiModelProperty(name = "职务/角色名称")
|
||||||
|
|||||||
+4
@@ -17,6 +17,10 @@ public class RoleDo extends BaseVOEntity implements Serializable {
|
|||||||
private Long parentRoleId;
|
private Long parentRoleId;
|
||||||
@ApiModelProperty(name = "组织表ID")
|
@ApiModelProperty(name = "组织表ID")
|
||||||
private Long organizationId;
|
private Long organizationId;
|
||||||
|
@ApiModelProperty(name = "组织名称")
|
||||||
|
private String organizationName;
|
||||||
|
@ApiModelProperty(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
@ApiModelProperty(name = "角色业务场景数据字典ID")
|
@ApiModelProperty(name = "角色业务场景数据字典ID")
|
||||||
private Long roleBusinessExampleId;
|
private Long roleBusinessExampleId;
|
||||||
@ApiModelProperty(name = "角色业务场景名称")
|
@ApiModelProperty(name = "角色业务场景名称")
|
||||||
|
|||||||
+19
@@ -1,6 +1,7 @@
|
|||||||
package com.mhd.user.domain.userAggregate.entity;
|
package com.mhd.user.domain.userAggregate.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
@@ -130,4 +131,22 @@ public class UserDriverEntity extends BaseVOEntity {
|
|||||||
|
|
||||||
@ApiModelProperty(name = "用户身份")
|
@ApiModelProperty(name = "用户身份")
|
||||||
private Integer userIdentity;
|
private Integer userIdentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级组织表ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织表ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "组织表ID")
|
||||||
|
private Long organizationId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "组织名称")
|
||||||
|
private String organizationName;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -197,4 +197,13 @@ public class UserShipperEntity extends BaseVOEntity {
|
|||||||
|
|
||||||
@ApiModelProperty("结算币种")
|
@ApiModelProperty("结算币种")
|
||||||
private String settlementCurrency;
|
private String settlementCurrency;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织表ID")
|
||||||
|
private Long organizationId;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织名称")
|
||||||
|
private String organizationName;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -26,6 +26,14 @@ public class UserDriverFactory {
|
|||||||
String userName = loginUser.getUsername();
|
String userName = loginUser.getUsername();
|
||||||
// 获取登录人id
|
// 获取登录人id
|
||||||
Long userId = loginUser.getUserid();
|
Long userId = loginUser.getUserid();
|
||||||
|
|
||||||
|
// 设置组织信息:如果 userDriverDO 中没有设置组织信息,则使用当前登录用户的组织信息
|
||||||
|
if (userDriverEntity.getOrganizationId() == null && loginUser.getUserPo() != null) {
|
||||||
|
userDriverEntity.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
userDriverEntity.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
userDriverEntity.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||||
|
}
|
||||||
|
|
||||||
if(userDriverDO.getDriverId() != null){
|
if(userDriverDO.getDriverId() != null){
|
||||||
if(userId != null){
|
if(userId != null){
|
||||||
userDriverEntity.setUpdateBy(userId);
|
userDriverEntity.setUpdateBy(userId);
|
||||||
@@ -55,6 +63,8 @@ public class UserDriverFactory {
|
|||||||
UserDriverEntity userDriverEntity = new UserDriverEntity();
|
UserDriverEntity userDriverEntity = new UserDriverEntity();
|
||||||
BeanUtils.copyProperties(userDriverDO,userDriverEntity, IgnoreNullUtil.getNullPropertyNames(userDriverDO));
|
BeanUtils.copyProperties(userDriverDO,userDriverEntity, IgnoreNullUtil.getNullPropertyNames(userDriverDO));
|
||||||
|
|
||||||
|
// 设置组织信息:从 userDriverDO 中复制,如果为空则保持null(开放接口可能由外部系统设置)
|
||||||
|
|
||||||
if(userDriverDO.getDriverId() != null){
|
if(userDriverDO.getDriverId() != null){
|
||||||
userDriverEntity.setUpdateBy(new Long("0"));
|
userDriverEntity.setUpdateBy(new Long("0"));
|
||||||
userDriverEntity.setUpdateTime(new Date());
|
userDriverEntity.setUpdateTime(new Date());
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ public interface UserRepositoryInterface extends IService<UserEntity> {
|
|||||||
|
|
||||||
UserEntity selectByTopOrganizationId(Long organizationId);
|
UserEntity selectByTopOrganizationId(Long organizationId);
|
||||||
|
|
||||||
List<QueryAllShipperInfoVo> findAllShipperInfo(Long userId, Long topOrganizationId);
|
List<QueryAllShipperInfoVo> findAllShipperInfo(Long userId, Long organizationId);
|
||||||
|
|
||||||
|
|
||||||
String finShipperEnterpriseNamedByUserId(Long userId);
|
String finShipperEnterpriseNamedByUserId(Long userId);
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ public interface UserMapper extends BaseMapper<UserEntity> {
|
|||||||
UserEntity selectByTopOrganizationId(@Param("organizationId") Long organizationId);
|
UserEntity selectByTopOrganizationId(@Param("organizationId") Long organizationId);
|
||||||
|
|
||||||
|
|
||||||
List<QueryAllShipperInfoVo> findAllShipperInfo(@Param("userId") Long userId, @Param("topOrganizationId") Long topOrganizationId);
|
List<QueryAllShipperInfoVo> findAllShipperInfo(@Param("userId") Long userId, @Param("organizationId") Long organizationId);
|
||||||
|
|
||||||
|
|
||||||
String finShipperEnterpriseNamedByUserId(@Param("userId") Long userId);
|
String finShipperEnterpriseNamedByUserId(@Param("userId") Long userId);
|
||||||
|
|||||||
+2
-2
@@ -160,8 +160,8 @@ public class UserRepositoryImpl extends ServiceImpl<UserMapper,UserEntity> imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<QueryAllShipperInfoVo> findAllShipperInfo(Long userId, Long topOrganizationId) {
|
public List<QueryAllShipperInfoVo> findAllShipperInfo(Long userId, Long organizationId) {
|
||||||
return userMapper.findAllShipperInfo(userId,topOrganizationId);
|
return userMapper.findAllShipperInfo(userId, organizationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-1
@@ -100,8 +100,12 @@ public class UserShipperPo implements Serializable {
|
|||||||
@ApiModelProperty(name = "营业执照照片")
|
@ApiModelProperty(name = "营业执照照片")
|
||||||
private String shipperEnterpriseLicenseFrontUrl = "";
|
private String shipperEnterpriseLicenseFrontUrl = "";
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织表ID")
|
||||||
|
private Long organizationId;
|
||||||
@ApiModelProperty(name = "组织名称")
|
@ApiModelProperty(name = "组织名称")
|
||||||
private String organizationName = "";
|
private String organizationName;
|
||||||
|
// @ApiModelProperty(name = '一级组织表ID')
|
||||||
|
private Long topOrganizationId;
|
||||||
@ApiModelProperty(name = "创建者姓名")
|
@ApiModelProperty(name = "创建者姓名")
|
||||||
private String createByName = "";
|
private String createByName = "";
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -246,8 +246,8 @@ public class UserDomainService {
|
|||||||
return userRepositoryInterface.selectByTopOrganizationId(organizationId);
|
return userRepositoryInterface.selectByTopOrganizationId(organizationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QueryAllShipperInfoVo> findAllShipperInfo(Long userId, Long topOrganizationId) {
|
public List<QueryAllShipperInfoVo> findAllShipperInfo(Long userId, Long organizationId) {
|
||||||
return userRepositoryInterface.findAllShipperInfo(userId,topOrganizationId);
|
return userRepositoryInterface.findAllShipperInfo(userId, organizationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String findUserNameByUserId(Long userId){
|
public String findUserNameByUserId(Long userId){
|
||||||
|
|||||||
+60
-2
@@ -92,13 +92,71 @@ public class UserDriverDomainService {
|
|||||||
*/
|
*/
|
||||||
// @DataPermissions(cacheName = "master")
|
// @DataPermissions(cacheName = "master")
|
||||||
public List<UserDriverListPo> userDriverList(UserDriverDO userDriverDO) {
|
public List<UserDriverListPo> userDriverList(UserDriverDO userDriverDO) {
|
||||||
|
// 首先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = userDriverDO.getOrganizationId();
|
||||||
|
|
||||||
//获取当前登陆人
|
//获取当前登陆人
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
if (loginUser.getUserPo().getBusinessType() == 2){
|
if (loginUser.getUserPo().getBusinessType() == 2){
|
||||||
userDriverDO.setCreateBy(loginUser.getUserPo().getUserId());
|
userDriverDO.setCreateBy(loginUser.getUserPo().getUserId());
|
||||||
userDriverDO.setOrganizationId(null);
|
// 当 businessType == 2 时,如果前端没有传递 organizationId,清空组织过滤条件
|
||||||
|
if (frontendOrganizationId == null) {
|
||||||
|
userDriverDO.setOrganizationId(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
userDriverDO.setTopOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
|
// 数据权限:查询权限根据 organizationId 来设置
|
||||||
|
// 当 organizationId 是 2827 时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤(包括2827)
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
userDriverDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
userDriverDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
userDriverDO.setOrganizationId(null);
|
||||||
|
userDriverDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织(包括南光)的数据
|
||||||
|
// 如果其他组织尝试查询南光(organizationId=2827)的数据,返回空数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (frontendOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织尝试查询南光的数据,设置一个不存在的 organizationId,返回空数据
|
||||||
|
userDriverDO.setOrganizationId(-1L);
|
||||||
|
userDriverDO.setTopOrganizationId(null);
|
||||||
|
} else if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
userDriverDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userDriverDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
userDriverDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userDriverDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
userDriverDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
userDriverDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return userDriverRepositoryInterface.userDriverList(userDriverDO);
|
return userDriverRepositoryInterface.userDriverList(userDriverDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -49,10 +49,13 @@ public class UserShipperDomainService {
|
|||||||
|
|
||||||
// @DataPermissions(cacheName = "master")
|
// @DataPermissions(cacheName = "master")
|
||||||
public List<UserShipperPo> userShipperList(UserShipperDO userShipperDO) {
|
public List<UserShipperPo> userShipperList(UserShipperDO userShipperDO) {
|
||||||
|
// 数据权限逻辑已在 UserShipperApplicationService.userShipperList 中处理
|
||||||
|
// 这里不再重复处理数据权限,直接使用传入的参数进行查询
|
||||||
|
|
||||||
//获取当前登陆人
|
//获取当前登陆人
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
userShipperDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
if(loginUser != null && loginUser.getUserPo() != null &&
|
||||||
if(loginUser.getUserPo().getBusinessType()==1||loginUser.getUserPo().getBusinessType()==3||loginUser.getUserPo().getUserAccountType()==5){
|
(loginUser.getUserPo().getBusinessType()==1||loginUser.getUserPo().getBusinessType()==3||loginUser.getUserPo().getUserAccountType()==5)){
|
||||||
userShipperDO.setUserId(loginUser.getUserid());
|
userShipperDO.setUserId(loginUser.getUserid());
|
||||||
}
|
}
|
||||||
return userShipperRepositoryInterface.selectList(userShipperDO);
|
return userShipperRepositoryInterface.selectList(userShipperDO);
|
||||||
|
|||||||
+22
-6
@@ -278,9 +278,17 @@ public class UserWlhyDomainService {
|
|||||||
tmsShipperDTO.setIdCardEndDate(idCardEndDate);
|
tmsShipperDTO.setIdCardEndDate(idCardEndDate);
|
||||||
Date idCardStartDate = DateUtil.parse(userPo.getUserIdcardDateFrom());
|
Date idCardStartDate = DateUtil.parse(userPo.getUserIdcardDateFrom());
|
||||||
tmsShipperDTO.setIdCardStartDate(idCardStartDate);
|
tmsShipperDTO.setIdCardStartDate(idCardStartDate);
|
||||||
tmsShipperDTO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
// 优先使用 userShipperEntity 对象中保存的组织信息,确保与数据库中的组织ID一致
|
||||||
tmsShipperDTO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
// 如果 userShipperEntity 中没有组织信息,则使用当前登录用户的组织信息作为后备
|
||||||
tmsShipperDTO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
if (userShipperEntity.getOrganizationId() != null) {
|
||||||
|
tmsShipperDTO.setOrganizationId(userShipperEntity.getOrganizationId());
|
||||||
|
tmsShipperDTO.setOrganizationName(userShipperEntity.getOrganizationName());
|
||||||
|
tmsShipperDTO.setTopOrganizationId(userShipperEntity.getTopOrganizationId());
|
||||||
|
} else if (loginUser.getUserPo() != null) {
|
||||||
|
tmsShipperDTO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
tmsShipperDTO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||||
|
tmsShipperDTO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
}
|
||||||
tmsShipperDTO.setCompanyName(userShipperEntity.getShipperEnterpriseName());
|
tmsShipperDTO.setCompanyName(userShipperEntity.getShipperEnterpriseName());
|
||||||
return tmsShipperDTO;
|
return tmsShipperDTO;
|
||||||
}
|
}
|
||||||
@@ -640,9 +648,17 @@ public class UserWlhyDomainService {
|
|||||||
TmsDriverAddOrUpdateDTO tmsDriverAddOrUpdateDTO = new TmsDriverAddOrUpdateDTO();
|
TmsDriverAddOrUpdateDTO tmsDriverAddOrUpdateDTO = new TmsDriverAddOrUpdateDTO();
|
||||||
tmsDriverAddOrUpdateDTO.setAddress(userPo.getUserAreaAddress());
|
tmsDriverAddOrUpdateDTO.setAddress(userPo.getUserAreaAddress());
|
||||||
tmsDriverAddOrUpdateDTO.setRegisteredAddress(userPo.getUserAreaAddress());
|
tmsDriverAddOrUpdateDTO.setRegisteredAddress(userPo.getUserAreaAddress());
|
||||||
tmsDriverAddOrUpdateDTO.setTopOrganizationId(userPo.getTopOrganizationId());
|
// 优先使用 userDriverDO 对象中保存的组织信息,确保与数据库中的组织ID一致
|
||||||
tmsDriverAddOrUpdateDTO.setOrganizationId(userPo.getOrganizationId());
|
// 如果 userDriverDO 中没有组织信息,则使用 userPo 中的组织信息作为后备
|
||||||
tmsDriverAddOrUpdateDTO.setOrganizationName(userPo.getOrganizationName());
|
if (userDriverDO.getOrganizationId() != null) {
|
||||||
|
tmsDriverAddOrUpdateDTO.setTopOrganizationId(userDriverDO.getTopOrganizationId());
|
||||||
|
tmsDriverAddOrUpdateDTO.setOrganizationId(userDriverDO.getOrganizationId());
|
||||||
|
tmsDriverAddOrUpdateDTO.setOrganizationName(userDriverDO.getOrganizationName());
|
||||||
|
} else if (userPo != null) {
|
||||||
|
tmsDriverAddOrUpdateDTO.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||||
|
tmsDriverAddOrUpdateDTO.setOrganizationId(userPo.getOrganizationId());
|
||||||
|
tmsDriverAddOrUpdateDTO.setOrganizationName(userPo.getOrganizationName());
|
||||||
|
}
|
||||||
tmsDriverAddOrUpdateDTO.setSzwlUserId(userDriverDO.getUserId());
|
tmsDriverAddOrUpdateDTO.setSzwlUserId(userDriverDO.getUserId());
|
||||||
Integer type = userDriverDO.getDriverType() != 1 ? 1 : 0;
|
Integer type = userDriverDO.getDriverType() != 1 ? 1 : 0;
|
||||||
tmsDriverAddOrUpdateDTO.setType(type);
|
tmsDriverAddOrUpdateDTO.setType(type);
|
||||||
|
|||||||
@@ -64,4 +64,10 @@ public class QueryAllShipperInfoVo {
|
|||||||
|
|
||||||
@ApiModelProperty(name = "客户nc编码")
|
@ApiModelProperty(name = "客户nc编码")
|
||||||
private String customerNcCode;
|
private String customerNcCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织ID")
|
||||||
|
private Long organizationId;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "一级组织ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,19 +20,19 @@ 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.102.192.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
|
||||||
# server-addr: 10.102.192.105:6848
|
|
||||||
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.102.192.5:6848
|
server-addr: 10.102.192.5:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
|
||||||
# server-addr: 10.102.192.105:6848
|
|
||||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||||
file-extension: yml #默认properties
|
file-extension: yml #默认properties
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|||||||
@@ -209,8 +209,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="organizationName != null and organizationName != ''">
|
<if test="organizationName != null and organizationName != ''">
|
||||||
and m.organization_name like concat('%', #{organizationName}, '%')
|
and m.organization_name like concat('%', #{organizationName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="topOrganizationId != null and topOrganizationId != ''">
|
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||||
and top_organization_id = #{topOrganizationId}
|
<if test="organizationId != null">
|
||||||
|
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||||
|
and m.organization_id = #{organizationId}
|
||||||
|
and m.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
<if test="topOrganizationId != null">
|
||||||
|
<!-- 如果设置了 topOrganizationId,添加 top_organization_id 条件 -->
|
||||||
|
and m.top_organization_id = #{topOrganizationId}
|
||||||
|
<if test="organizationId == null">
|
||||||
|
<!-- 如果没有设置 organizationId,添加 organization_name IS NOT NULL 条件 -->
|
||||||
|
and m.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
</if>
|
</if>
|
||||||
<if test="organizationIdList != null ">
|
<if test="organizationIdList != null ">
|
||||||
AND m.organization_id in
|
AND m.organization_id in
|
||||||
@@ -377,7 +388,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
motorcade_driver d
|
motorcade_driver d
|
||||||
ON m.motorcade_id = d.motorcade_id and d.del_flag = 1
|
ON m.motorcade_id = d.motorcade_id and d.del_flag = 1
|
||||||
where top_organization_id = #{organizationId} and m.del_flag = 1
|
<where>
|
||||||
|
m.del_flag = 1
|
||||||
|
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||||
|
<if test="organizationId != null">
|
||||||
|
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||||
|
and m.organization_id = #{organizationId}
|
||||||
|
and m.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
<if test="topOrganizationId != null">
|
||||||
|
<!-- 如果设置了 topOrganizationId,添加 top_organization_id 条件 -->
|
||||||
|
and m.top_organization_id = #{topOrganizationId}
|
||||||
|
<if test="organizationId == null">
|
||||||
|
<!-- 如果没有设置 organizationId,添加 organization_name IS NOT NULL 条件 -->
|
||||||
|
and m.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
a.role_id,
|
a.role_id,
|
||||||
a.parent_role_id,
|
a.parent_role_id,
|
||||||
a.organization_id,
|
a.organization_id,
|
||||||
|
a.organization_name AS organizationName,
|
||||||
|
a.top_organization_id AS topOrganizationId,
|
||||||
a.role_code,
|
a.role_code,
|
||||||
a.role_name,
|
a.role_name,
|
||||||
a.role_remark,
|
a.role_remark,
|
||||||
@@ -51,6 +53,7 @@
|
|||||||
a.del_flag = 1
|
a.del_flag = 1
|
||||||
<include refid="common_where"></include>
|
<include refid="common_where"></include>
|
||||||
GROUP BY a.role_id
|
GROUP BY a.role_id
|
||||||
|
ORDER BY COALESCE(a.update_time, a.create_time) DESC
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByOrganizationIdAndRoleCode"
|
<select id="selectByOrganizationIdAndRoleCode"
|
||||||
parameterType="com.mhd.user.domain.roleAggregate.repository.todo.RoleDo"
|
parameterType="com.mhd.user.domain.roleAggregate.repository.todo.RoleDo"
|
||||||
@@ -119,6 +122,16 @@
|
|||||||
</if>
|
</if>
|
||||||
<if test="organizationId !=null">
|
<if test="organizationId !=null">
|
||||||
and a.organization_id = #{organizationId}
|
and a.organization_id = #{organizationId}
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
<if test="topOrganizationId !=null">
|
||||||
|
and a.top_organization_id = #{topOrganizationId}
|
||||||
|
<if test="organizationId == null">
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
<if test="organizationName != null and organizationName != ''">
|
||||||
|
and a.organization_name like concat('%' , #{organizationName} , '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="organizationIds !=null">
|
<if test="organizationIds !=null">
|
||||||
and a.organization_id in
|
and a.organization_id in
|
||||||
|
|||||||
@@ -703,7 +703,10 @@
|
|||||||
<!-- </foreach>-->
|
<!-- </foreach>-->
|
||||||
<!-- </if>-->
|
<!-- </if>-->
|
||||||
|
|
||||||
<if test="userDriverDO.organizationId != null"> and b.organization_id = #{userDriverDO.organizationId}</if>
|
<if test="userDriverDO.organizationId != null">
|
||||||
|
and b.organization_id = #{userDriverDO.organizationId}
|
||||||
|
and b.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
<if test="userDriverDO.createBy != null">
|
<if test="userDriverDO.createBy != null">
|
||||||
and (b.create_by = #{userDriverDO.createBy}
|
and (b.create_by = #{userDriverDO.createBy}
|
||||||
or b.user_id = #{userDriverDO.createBy}
|
or b.user_id = #{userDriverDO.createBy}
|
||||||
|
|||||||
@@ -217,11 +217,19 @@
|
|||||||
and a.user_id = #{userId}
|
and a.user_id = #{userId}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="organizationId !=null">
|
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||||
|
<if test="organizationId != null">
|
||||||
|
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||||
and a.organization_id = #{organizationId}
|
and a.organization_id = #{organizationId}
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
</if>
|
</if>
|
||||||
<if test="topOrganizationId !=null">
|
<if test="topOrganizationId != null">
|
||||||
|
<!-- 如果设置了 topOrganizationId,添加 top_organization_id 条件 -->
|
||||||
and a.top_organization_id = #{topOrganizationId}
|
and a.top_organization_id = #{topOrganizationId}
|
||||||
|
<if test="organizationId == null">
|
||||||
|
<!-- 如果没有设置 organizationId,添加 organization_name IS NOT NULL 条件 -->
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
</if>
|
</if>
|
||||||
/*组织名称*/
|
/*组织名称*/
|
||||||
<if test="organizationName != null and organizationName != ''">
|
<if test="organizationName != null and organizationName != ''">
|
||||||
@@ -708,7 +716,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findAllShipperInfo" resultType="com.mhd.user.interfaces.vo.QueryAllShipperInfoVo">
|
<select id="findAllShipperInfo" resultType="com.mhd.user.interfaces.vo.QueryAllShipperInfoVo">
|
||||||
SELECT u.user_id, u.user_name, u.user_area_address, u.user_area_county_id, u.user_area_name ,u.user_phone,u.has_default_address,b.shipper_id,b.shipper_enterprise_name,u.DOCUMENT_PREPARER_NC_CODE,b.CUSTOMER_NC_CODE
|
SELECT u.user_id, u.user_name, u.user_area_address, u.user_area_county_id, u.user_area_name ,u.user_phone,u.has_default_address,b.shipper_id,b.shipper_enterprise_name,u.DOCUMENT_PREPARER_NC_CODE,b.CUSTOMER_NC_CODE,u.organization_id AS organizationId,u.top_organization_id AS topOrganizationId
|
||||||
FROM "USER" u
|
FROM "USER" u
|
||||||
LEFT JOIN user_shipper b ON u.user_id = b.user_id
|
LEFT JOIN user_shipper b ON u.user_id = b.user_id
|
||||||
left join (select user_id, LISTAGG(r.role_name, '&') WITHIN GROUP(ORDER BY r.role_name) AS roleName
|
left join (select user_id, LISTAGG(r.role_name, '&') WITHIN GROUP(ORDER BY r.role_name) AS roleName
|
||||||
@@ -723,9 +731,10 @@
|
|||||||
<if test="userId !=null">
|
<if test="userId !=null">
|
||||||
AND u.user_Id = #{userId}
|
AND u.user_Id = #{userId}
|
||||||
</if>
|
</if>
|
||||||
/*一级组织ID*/
|
/*组织ID - 数据隔离:南光组织(organizationId=2827)查询全部,其他组织查询自己组织的数据*/
|
||||||
<if test="topOrganizationId !=null">
|
<if test="organizationId !=null">
|
||||||
AND u.top_organization_id = #{topOrganizationId}
|
AND u.organization_id = #{organizationId}
|
||||||
|
AND u.organization_name IS NOT NULL
|
||||||
</if>
|
</if>
|
||||||
GROUP BY u.user_id
|
GROUP BY u.user_id
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -114,7 +114,8 @@
|
|||||||
b.shipper_enterprisel_auth_id,
|
b.shipper_enterprisel_auth_id,
|
||||||
a.user_phone,
|
a.user_phone,
|
||||||
a.user_name,
|
a.user_name,
|
||||||
a.organization_name,
|
a.organization_id AS organizationId,
|
||||||
|
a.organization_name AS organizationName,
|
||||||
a.user_account,
|
a.user_account,
|
||||||
a.user_member_code,
|
a.user_member_code,
|
||||||
a.user_idcard_number,
|
a.user_idcard_number,
|
||||||
|
|||||||
+60
-4
@@ -124,11 +124,51 @@ public class BusinessDocumentApplicationService {
|
|||||||
|
|
||||||
public List<BusinessDocumentPO> queryList(BusinessDocumentDO businessDocumentDO) {
|
public List<BusinessDocumentPO> queryList(BusinessDocumentDO businessDocumentDO) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("运单管理查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return businessDocumentDomainService.queryList(businessDocumentDO);
|
||||||
|
}
|
||||||
|
|
||||||
UserPo userPo = loginUser.getUserPo();
|
UserPo userPo = loginUser.getUserPo();
|
||||||
if (userPo.getUserAccountType() == 3){
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
businessDocumentDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
}else {
|
|
||||||
businessDocumentDO.setOrganizationId(userPo.getOrganizationId());
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = businessDocumentDO.getOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
businessDocumentDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
businessDocumentDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
businessDocumentDO.setOrganizationId(null);
|
||||||
|
businessDocumentDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:根据userAccountType设置组织过滤
|
||||||
|
if (userPo.getUserAccountType() == 3){
|
||||||
|
// 租户管理员:使用topOrganizationId
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
businessDocumentDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
businessDocumentDO.setOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 其他用户:使用organizationId
|
||||||
|
if (frontendOrganizationId != null && !frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("运单管理查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
businessDocumentDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else if (frontendOrganizationId == null) {
|
||||||
|
businessDocumentDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
businessDocumentDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return businessDocumentDomainService.queryList(businessDocumentDO);
|
return businessDocumentDomainService.queryList(businessDocumentDO);
|
||||||
}
|
}
|
||||||
@@ -1347,6 +1387,21 @@ public class BusinessDocumentApplicationService {
|
|||||||
detail.setUpdateBy(loginUser.getUserid());
|
detail.setUpdateBy(loginUser.getUserid());
|
||||||
detail.setUpdateByName(loginUser.getUsername());
|
detail.setUpdateByName(loginUser.getUsername());
|
||||||
detail.setUpdateTime(now);
|
detail.setUpdateTime(now);
|
||||||
|
// 设置审核人的组织ID和组织名称
|
||||||
|
if (loginUser.getUserPo() != null) {
|
||||||
|
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
String organizationName = loginUser.getUserPo().getOrganizationName();
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
if (organizationId != null) {
|
||||||
|
detail.setOrganizationId(organizationId);
|
||||||
|
}
|
||||||
|
if (organizationName != null) {
|
||||||
|
detail.setOrganizationName(organizationName);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
detail.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
businessDocumentDetaliUpdateList.add(detail);
|
businessDocumentDetaliUpdateList.add(detail);
|
||||||
|
|
||||||
BusinessDocumentDetaliDTO detailDto = new BusinessDocumentDetaliDTO();
|
BusinessDocumentDetaliDTO detailDto = new BusinessDocumentDetaliDTO();
|
||||||
@@ -1401,6 +1456,7 @@ public class BusinessDocumentApplicationService {
|
|||||||
Verification verification = new Verification();
|
Verification verification = new Verification();
|
||||||
verification.setOrganizationId(businessDocumentDetaliDTO.getOrganizationId());
|
verification.setOrganizationId(businessDocumentDetaliDTO.getOrganizationId());
|
||||||
verification.setTopOrganizationId(businessDocumentDetaliDTO.getTopOrganizationId());
|
verification.setTopOrganizationId(businessDocumentDetaliDTO.getTopOrganizationId());
|
||||||
|
verification.setOrganizationName(businessDocumentDetaliDTO.getOrganizationName());
|
||||||
verification.setVerificationStatus(1);//未支付
|
verification.setVerificationStatus(1);//未支付
|
||||||
verification.setBusinessDocumentDetaliId(businessDocumentDetaliDTO.getBusinessDocumentDetaliId());
|
verification.setBusinessDocumentDetaliId(businessDocumentDetaliDTO.getBusinessDocumentDetaliId());
|
||||||
verification.setBusinessDocumentDetaliNumber(businessDocumentDetaliDTO.getBusinessDocumentDetaliNumber());
|
verification.setBusinessDocumentDetaliNumber(businessDocumentDetaliDTO.getBusinessDocumentDetaliNumber());
|
||||||
|
|||||||
+5
-4
@@ -56,7 +56,7 @@ public class ReceivingAccountApplicationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增收款账户(先删除所有,再新增)
|
* 批量新增收款账户(追加式新增,不删除旧数据)
|
||||||
*
|
*
|
||||||
* @param receivingAccountDTOList 收款账户DTO列表
|
* @param receivingAccountDTOList 收款账户DTO列表
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
@@ -65,9 +65,10 @@ public class ReceivingAccountApplicationService {
|
|||||||
public Boolean batchInsert(List<ReceivingAccountDO> receivingAccountDTOList) {
|
public Boolean batchInsert(List<ReceivingAccountDO> receivingAccountDTOList) {
|
||||||
log.info("批量新增收款账户,数量:{}", receivingAccountDTOList.size());
|
log.info("批量新增收款账户,数量:{}", receivingAccountDTOList.size());
|
||||||
|
|
||||||
// 先删除所有现有数据
|
if (receivingAccountDTOList == null || receivingAccountDTOList.isEmpty()) {
|
||||||
int deleteCount = receivingAccountRepository.deleteAll();
|
log.warn("批量新增收款账户:数据列表为空");
|
||||||
log.info("已删除现有收款账户数量:{}", deleteCount);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
List<ReceivingAccount> receivingAccountList = new ArrayList<>();
|
List<ReceivingAccount> receivingAccountList = new ArrayList<>();
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|||||||
+60
-8
@@ -85,15 +85,65 @@ public class ReconciliationApplicationService {
|
|||||||
public List<ReconciliationPO> queryList(ReconciliationDO reconciliationDO) {
|
public List<ReconciliationPO> queryList(ReconciliationDO reconciliationDO) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
UserPo userPo = loginUser.getUserPo();
|
UserPo userPo = loginUser.getUserPo();
|
||||||
if (userPo.getUserAccountType() == 3) {
|
|
||||||
reconciliationDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
} else if (userPo.getUserAccountType() == 2){
|
Long frontendOrganizationId = reconciliationDO.getOrganizationId();
|
||||||
reconciliationDO.setOrganizationId(userPo.getOrganizationId());
|
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤(包括2827)
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
reconciliationDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
reconciliationDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
reconciliationDO.setOrganizationId(null);
|
||||||
|
reconciliationDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (loginUser.getRoleList().contains(RoleEnum.SHIPPER.getCode()) || loginUser.getRoleList().contains(RoleEnum.COMPANY.getCode())){
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
reconciliationDO.setUserId(userPo.getUserId());
|
// 其他组织只能查询自己组织的数据,不能查询其他组织(包括南光)的数据
|
||||||
}else {
|
// 如果其他组织尝试查询南光(organizationId=2827)的数据,返回空数据
|
||||||
reconciliationDO.setOrganizationId(userPo.getOrganizationId());
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (frontendOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织尝试查询南光的数据,设置一个不存在的 organizationId,返回空数据
|
||||||
|
reconciliationDO.setOrganizationId(-1L);
|
||||||
|
reconciliationDO.setTopOrganizationId(null);
|
||||||
|
} else if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
reconciliationDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
reconciliationDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
reconciliationDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
reconciliationDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,根据用户账号类型设置组织过滤条件
|
||||||
|
if (userPo.getUserAccountType() == 3) {
|
||||||
|
reconciliationDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
} else if (userPo.getUserAccountType() == 2){
|
||||||
|
reconciliationDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
if (loginUser.getRoleList().contains(RoleEnum.SHIPPER.getCode()) || loginUser.getRoleList().contains(RoleEnum.COMPANY.getCode())){
|
||||||
|
reconciliationDO.setUserId(userPo.getUserId());
|
||||||
|
}else {
|
||||||
|
reconciliationDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ReconciliationPO> reconciliationPOS = reconciliationDomainService.queryList(reconciliationDO);
|
List<ReconciliationPO> reconciliationPOS = reconciliationDomainService.queryList(reconciliationDO);
|
||||||
@@ -111,6 +161,8 @@ public class ReconciliationApplicationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reconciliationPOS;
|
return reconciliationPOS;
|
||||||
|
|
||||||
|
return reconciliationDomainService.queryList(reconciliationDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+72
-5
@@ -50,13 +50,80 @@ public class TmsReceiptApplicationService {
|
|||||||
|
|
||||||
public List<TmsReceiptPO> queryList(TmsReceiptDO tmsReceiptDO) {
|
public List<TmsReceiptPO> queryList(TmsReceiptDO tmsReceiptDO) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser != null){
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
log.warn("收款单查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
if (topOrganizationId != null && topOrganizationId != 1){
|
return tmsReceiptDomainService.queryList(tmsReceiptDO);
|
||||||
tmsReceiptDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
}
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = tmsReceiptDO.getOrganizationId();
|
||||||
|
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
|
||||||
|
log.info("收款单查询 - 开始数据权限处理 - 登录用户组织ID: {}, topOrganizationId: {}, 前端传递组织ID: {}",
|
||||||
|
loginUserOrganizationId, topOrganizationId, frontendOrganizationId);
|
||||||
|
|
||||||
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤(包括2827)
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
tmsReceiptDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
tmsReceiptDO.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
tmsReceiptDO.setOrganizationId(null);
|
||||||
|
tmsReceiptDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织(包括南光)的数据
|
||||||
|
// 如果其他组织尝试查询南光(organizationId=2827)的数据,返回空数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (frontendOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织尝试查询南光的数据,设置一个不存在的 organizationId,返回空数据
|
||||||
|
tmsReceiptDO.setOrganizationId(-1L);
|
||||||
|
tmsReceiptDO.setTopOrganizationId(null);
|
||||||
|
} else if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
tmsReceiptDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||||
|
tmsReceiptDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
tmsReceiptDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||||
|
tmsReceiptDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,根据用户组织信息设置过滤条件
|
||||||
|
// 优先使用 topOrganizationId(如果存在且不等于1),否则使用 organizationId
|
||||||
|
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||||
|
tmsReceiptDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
tmsReceiptDO.setOrganizationId(null);
|
||||||
|
} else if (loginUserOrganizationId != null) {
|
||||||
|
tmsReceiptDO.setOrganizationId(loginUserOrganizationId);
|
||||||
|
tmsReceiptDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tmsReceiptDomainService.queryList(tmsReceiptDO);
|
|
||||||
|
// 调试日志:打印设置的查询条件
|
||||||
|
log.info("收款单查询 - 数据权限处理完成 - 登录用户组织ID: {}, 前端传递组织ID: {}, 最终查询条件 - organizationId: {}, topOrganizationId: {}, 是否为南光组织: {}",
|
||||||
|
loginUserOrganizationId, frontendOrganizationId, tmsReceiptDO.getOrganizationId(), tmsReceiptDO.getTopOrganizationId(),
|
||||||
|
(loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)));
|
||||||
|
|
||||||
|
List<TmsReceiptPO> result = tmsReceiptDomainService.queryList(tmsReceiptDO);
|
||||||
|
log.info("收款单查询 - 查询完成,返回数据条数: {}", result != null ? result.size() : 0);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
@@ -351,6 +351,12 @@ public class InvoiceInfoManageApplicationService {
|
|||||||
|
|
||||||
//数据装配
|
//数据装配
|
||||||
InvoiceInfo invoiceInfo = new InvoiceAssembler().toDo(invoiceInfoDto);
|
InvoiceInfo invoiceInfo = new InvoiceAssembler().toDo(invoiceInfoDto);
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
com.mhd.system.api.model.LoginUser loginUser = com.mhd.common.security.utils.SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
invoiceInfo.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
invoiceInfo.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
}
|
||||||
invoiceInfo.setInvoiceStatus(1);
|
invoiceInfo.setInvoiceStatus(1);
|
||||||
invoiceInfo.setInvoiceHeader(invoiceInfoManagePo.getInvoiceHeader());
|
invoiceInfo.setInvoiceHeader(invoiceInfoManagePo.getInvoiceHeader());
|
||||||
invoiceInfo.setWaybillAmount(new BigDecimal(invoiceInfoDto.getInvoiceOrderIds().length));
|
invoiceInfo.setWaybillAmount(new BigDecimal(invoiceInfoDto.getInvoiceOrderIds().length));
|
||||||
|
|||||||
+6
@@ -137,6 +137,12 @@ public class RevenueExpensesRecordApplicationService
|
|||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
if (loginUser.getUserPo() != null) {
|
||||||
|
revenueExpensesRecord.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
revenueExpensesRecord.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
}
|
||||||
|
|
||||||
//支付通道
|
//支付通道
|
||||||
if(StringUtils.isNotEmpty(revenueExpensesRecord.getPayChannel())){
|
if(StringUtils.isNotEmpty(revenueExpensesRecord.getPayChannel())){
|
||||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
||||||
|
|||||||
+46
-32
@@ -151,44 +151,58 @@ public class VerificationApplicationService
|
|||||||
* @return 收入核销集合
|
* @return 收入核销集合
|
||||||
*/
|
*/
|
||||||
public List<VerificationPo> selectVerificationList(VerificationPo verificationPo){
|
public List<VerificationPo> selectVerificationList(VerificationPo verificationPo){
|
||||||
List<VerificationPo> list = new ArrayList<>();
|
|
||||||
List<Long> organizationIdList = new ArrayList<>();
|
|
||||||
//获取登录人信息
|
//获取登录人信息
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("应付账单查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return verificationDomainService.selectVerificationList(verificationPo);
|
||||||
|
}
|
||||||
|
|
||||||
UserPo userPo = loginUser.getUserPo();
|
UserPo userPo = loginUser.getUserPo();
|
||||||
//当前组织id
|
|
||||||
Long organizationId = new Long("2");
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
OrganizationPo organizationPo = loginUser.getOrganizationPo();
|
Long frontendOrganizationId = verificationPo.getOrganizationId();
|
||||||
if (organizationPo == null){
|
|
||||||
organizationIdList.add(userPo.getOrganizationId());
|
// 获取当前登录用户的组织信息
|
||||||
}else {
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
List<Long> organizationIdList1 = organizationPo.getOrganizationIdList();
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
if (organizationIdList1 != null && organizationIdList1.size() > 0){
|
|
||||||
organizationIdList.addAll(organizationIdList1);
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
}else {
|
// topOrganizationId为null时,为顶级组织(南光组织),查所有;其他组织查自己
|
||||||
organizationIdList.add(organizationPo.getOrganizationId());
|
if (topOrganizationId == null) {
|
||||||
|
// 南光组织:可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
verificationPo.setOrganizationId(frontendOrganizationId);
|
||||||
|
verificationPo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
verificationPo.setOrganizationId(null);
|
||||||
|
verificationPo.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
verificationPo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
verificationPo.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
verificationPo.setTopOrganizationId(topOrganizationId);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
verificationPo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
verificationPo.setTopOrganizationId(topOrganizationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(loginUser != null){
|
|
||||||
// if(loginUser.getUserPo() != null && loginUser.getUserPo().getOrganizationId() != null){
|
|
||||||
// organizationId = loginUser.getUserPo().getOrganizationId();
|
|
||||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
|
||||||
// if("200".equals(String.valueOf(info.get("code")))){
|
|
||||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
|
||||||
// verificationPo.setBranchId(branchPo.getBranchId());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
if (organizationIdList != null && organizationIdList.size() > 0){
|
|
||||||
organizationIdList.add(userPo.getOrganizationId());
|
|
||||||
}
|
|
||||||
// verificationPo.setOrganizationIdList(organizationIdList);
|
|
||||||
// verificationPo.setVerificationType(2);
|
|
||||||
// if (StringUtils.isNotBlank(verificationPo.getWaybillNumbers())){
|
|
||||||
// verificationPo.setWaybillNumberList(CollectionUtil.toList(verificationPo.getWaybillNumbers().split(",")));
|
|
||||||
// }
|
|
||||||
return verificationDomainService.selectOutVerificationList(verificationPo);
|
return verificationDomainService.selectOutVerificationList(verificationPo);
|
||||||
// return verificationDomainService.selectVerificationList(verificationPo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+5
@@ -58,6 +58,11 @@ public class InvoiceOrderDomainService
|
|||||||
*/
|
*/
|
||||||
public int insertInvoiceOrder(InvoiceOrder invoiceOrder)
|
public int insertInvoiceOrder(InvoiceOrder invoiceOrder)
|
||||||
{
|
{
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
com.mhd.system.api.model.LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
invoiceOrder.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
}
|
||||||
invoiceOrder.setCreateTime(new Date());
|
invoiceOrder.setCreateTime(new Date());
|
||||||
invoiceOrder.setCreateBy(SecurityUtils.getUserId());
|
invoiceOrder.setCreateBy(SecurityUtils.getUserId());
|
||||||
invoiceOrder.setCreateByName(SecurityUtils.getUsername());
|
invoiceOrder.setCreateByName(SecurityUtils.getUsername());
|
||||||
|
|||||||
+10
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.linke.finance.domain.receivingAccount.entity.ReceivingAccount;
|
import com.linke.finance.domain.receivingAccount.entity.ReceivingAccount;
|
||||||
import com.linke.finance.domain.receivingAccount.repository.po.ReceivingAccountPO;
|
import com.linke.finance.domain.receivingAccount.repository.po.ReceivingAccountPO;
|
||||||
import com.linke.finance.domain.receivingAccount.repository.todo.ReceivingAccountDO;
|
import com.linke.finance.domain.receivingAccount.repository.todo.ReceivingAccountDO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -46,6 +47,15 @@ public interface ReceivingAccountMapper extends BaseMapper<ReceivingAccount> {
|
|||||||
*/
|
*/
|
||||||
int deleteAll();
|
int deleteAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据组织ID删除收款账户(删除当前组织的所有收款账户)
|
||||||
|
*
|
||||||
|
* @param topOrganizationId 一级组织ID
|
||||||
|
* @param organizationId 组织ID
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int deleteByOrganization(@Param("topOrganizationId") String topOrganizationId, @Param("organizationId") String organizationId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID删除收款账户
|
* 根据ID删除收款账户
|
||||||
*
|
*
|
||||||
|
|||||||
+11
@@ -60,6 +60,17 @@ public class ReceivingAccountRepository {
|
|||||||
return receivingAccountMapper.deleteAll();
|
return receivingAccountMapper.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据组织ID删除收款账户(删除当前组织的所有收款账户)
|
||||||
|
*
|
||||||
|
* @param topOrganizationId 一级组织ID
|
||||||
|
* @param organizationId 组织ID
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
public int deleteByOrganization(String topOrganizationId, String organizationId) {
|
||||||
|
return receivingAccountMapper.deleteByOrganization(topOrganizationId, organizationId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID删除收款账户
|
* 根据ID删除收款账户
|
||||||
*
|
*
|
||||||
|
|||||||
+17
-50
@@ -389,21 +389,6 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
|||||||
LoginUser loginUser= SecurityUtils.getLoginUser();
|
LoginUser loginUser= SecurityUtils.getLoginUser();
|
||||||
UserPo userPo=loginUser.getUserPo();
|
UserPo userPo=loginUser.getUserPo();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
AjaxResult ajaxResult5=userServiceFeign.getInfo(loginUser.getUserid());
|
|
||||||
if(ajaxResult5.get("code").toString().equals("200")){
|
|
||||||
Object userShipperPo= ajaxResult5.get("data");
|
|
||||||
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
|
|
||||||
|
|
||||||
try {
|
|
||||||
String jsonString = mapper.writeValueAsString(jsonObject);
|
|
||||||
userPo = mapper.readValue(jsonString, UserPo.class);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
throw new ServiceException("查询当前登录人用户信息失败");
|
|
||||||
}
|
|
||||||
for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){
|
for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){
|
||||||
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
|
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
|
||||||
if(reconciliation.getSynchronousStatus()==1){
|
if(reconciliation.getSynchronousStatus()==1){
|
||||||
@@ -435,15 +420,18 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
|||||||
TmsTransportNote tmsTransportNote= ajaxResult1.getData();
|
TmsTransportNote tmsTransportNote= ajaxResult1.getData();
|
||||||
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
|
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
|
||||||
date=tmsTransportNote.getConfirmReceiptTime();
|
date=tmsTransportNote.getConfirmReceiptTime();
|
||||||
|
if(null==date){
|
||||||
|
date=new Date();
|
||||||
|
}
|
||||||
dateString = sdf.format(date);
|
dateString = sdf.format(date);
|
||||||
}else{
|
}else{
|
||||||
throw new ServiceException("运单还没签收, 先签收");
|
throw new ServiceException("运单还没签收, 先签收");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(null==reconciliation.getSettlementPartyId()){
|
/* if(null==reconciliation.getSettlementPartyId()){
|
||||||
throw new ServiceException("没有结算方,请核对");
|
throw new ServiceException("没有结算方,请核对");
|
||||||
}
|
}*/
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) {
|
/* if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) {
|
||||||
throw new ServiceException("请先维护业务员编码");
|
throw new ServiceException("请先维护业务员编码");
|
||||||
}
|
}
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getMakerCodeNc())) {
|
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getMakerCodeNc())) {
|
||||||
@@ -451,13 +439,13 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
|||||||
}
|
}
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) {
|
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) {
|
||||||
throw new ServiceException("请先维护制单员编码");
|
throw new ServiceException("请先维护制单员编码");
|
||||||
}
|
}*/
|
||||||
makerCodeNc=tmsOrder.getMakerCodeNc();
|
makerCodeNc=tmsOrder.getMakerCodeNc();
|
||||||
Ysitem item=new Ysitem();
|
Ysitem item=new Ysitem();
|
||||||
item.setSo_deptid("NG040104");
|
item.setSo_deptid("NG040104");
|
||||||
item.setPk_deptid("NG040104");
|
item.setPk_deptid("NG040104");
|
||||||
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
|
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
|
||||||
item.setCustomer(tmsOrder.getCustomsCodeNc());
|
item.setCustomer(tmsOrder.getCustomerCodeNc());
|
||||||
item.setObjtype("0");
|
item.setObjtype("0");
|
||||||
item.setDirection("1");
|
item.setDirection("1");
|
||||||
item.setScomment(tmsOrder.getAppointShipper());
|
item.setScomment(tmsOrder.getAppointShipper());
|
||||||
@@ -468,7 +456,7 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
|||||||
item.setQuantity_de("0");
|
item.setQuantity_de("0");
|
||||||
item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight()));
|
item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight()));
|
||||||
item.setMoney_bal(String.valueOf(tmsOrder.getDeliveryFreight()));
|
item.setMoney_bal(String.valueOf(tmsOrder.getDeliveryFreight()));
|
||||||
BigDecimal tax_de=tmsOrder.getDeliveryFreight().multiply(tmsOrder.getTaxRate()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal tax_de=tmsOrder.getDeliveryFreight().multiply(tmsOrder.getTaxRate().divide(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de);
|
BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de);
|
||||||
item.setNotax_de(String.valueOf(notax_de));
|
item.setNotax_de(String.valueOf(notax_de));
|
||||||
item.setLocal_tax_de(String.valueOf(notax_de));
|
item.setLocal_tax_de(String.valueOf(notax_de));
|
||||||
@@ -578,28 +566,6 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
|||||||
String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(",");
|
String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(",");
|
||||||
LoginUser loginUser= SecurityUtils.getLoginUser();
|
LoginUser loginUser= SecurityUtils.getLoginUser();
|
||||||
UserPo userPo=loginUser.getUserPo();
|
UserPo userPo=loginUser.getUserPo();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
AjaxResult ajaxResult5=userServiceFeign.getInfo(loginUser.getUserid());
|
|
||||||
if(ajaxResult5.get("code").toString().equals("200")){
|
|
||||||
Object userShipperPo= ajaxResult5.get("data");
|
|
||||||
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
|
|
||||||
|
|
||||||
try {
|
|
||||||
String jsonString = mapper.writeValueAsString(jsonObject);
|
|
||||||
userPo = mapper.readValue(jsonString, UserPo.class);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
throw new ServiceException("查询当前登录人用户信息失败");
|
|
||||||
}
|
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(userPo.getSalespersonNcCode())) {
|
|
||||||
throw new ServiceException("请先维护业务员编码");
|
|
||||||
}
|
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(userPo.getDocumentPreparerNcCode())) {
|
|
||||||
throw new ServiceException("请先维护制单员编码");
|
|
||||||
}
|
|
||||||
for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){
|
for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){
|
||||||
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
|
Reconciliation reconciliation=reconciliationMapper.selectById(businessDocumentDetaliId);
|
||||||
if(reconciliation.getSkSynchronousStatus()==1){
|
if(reconciliation.getSkSynchronousStatus()==1){
|
||||||
@@ -621,32 +587,33 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
|
|||||||
List<SKitem> ysitemList=new ArrayList<SKitem>();
|
List<SKitem> ysitemList=new ArrayList<SKitem>();
|
||||||
ReconciliationDTO reconciliationDTO=new ReconciliationDTO();
|
ReconciliationDTO reconciliationDTO=new ReconciliationDTO();
|
||||||
reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
|
reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
|
||||||
if(null==reconciliation.getSettlementPartyId()){
|
/* if(null==reconciliation.getSettlementPartyId()){
|
||||||
throw new ServiceException("没有结算方,请核对");
|
throw new ServiceException("没有结算方,请核对");
|
||||||
}
|
}*/
|
||||||
String makerCodeNc="";
|
String makerCodeNc="";
|
||||||
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
|
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
|
||||||
if(result.getCode()==200){
|
if(result.getCode()==200){
|
||||||
List<TmsOrder> list=result.getData();
|
List<TmsOrder> list=result.getData();
|
||||||
if(ObjectUtil.isNotNull(list)){
|
if(ObjectUtil.isNotNull(list)){
|
||||||
for(TmsOrder tmsOrder:list){
|
for(TmsOrder tmsOrder:list){
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) {
|
/* if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) {
|
||||||
throw new ServiceException("请先维护业务员编码");
|
throw new ServiceException("请先维护业务员编码");
|
||||||
}
|
}
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getMakerCodeNc())) {
|
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getMakerCodeNc())) {
|
||||||
throw new ServiceException("请先维护制单员编码");
|
throw new ServiceException("请先维护制单员编码");
|
||||||
}
|
}
|
||||||
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) {
|
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomerCodeNc())) {
|
||||||
throw new ServiceException("请先维护制单员编码");
|
throw new ServiceException("请先维护制单员编码");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
makerCodeNc=tmsOrder.getMakerCodeNc();
|
||||||
|
makerCodeNc="xiangna";
|
||||||
SKitem item=new SKitem();
|
SKitem item=new SKitem();
|
||||||
item.setSo_deptid("NG040104");
|
item.setSo_deptid("NG040104");
|
||||||
item.setPk_deptid("NG040104");
|
item.setPk_deptid("NG040104");
|
||||||
item.setCheckdirection("ar");
|
item.setCheckdirection("ar");
|
||||||
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
|
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
|
||||||
item.setCustomer(tmsOrder.getCustomsCodeNc());
|
item.setCustomer(tmsOrder.getCustomerCodeNc());
|
||||||
item.setPurchaseorder(tmsOrder.getGoodsNumber());
|
item.setPurchaseorder(tmsOrder.getGoodsNumber());
|
||||||
item.setObjtype("0");
|
item.setObjtype("0");
|
||||||
item.setDirection("1");
|
item.setDirection("1");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class TmsReceiptDTO extends BaseVOEntity{
|
|||||||
|
|
||||||
@ApiModelProperty("一级组织ID")
|
@ApiModelProperty("一级组织ID")
|
||||||
@Excel(name = "一级组织ID")
|
@Excel(name = "一级组织ID")
|
||||||
private Integer topOrganizationId;
|
private Long topOrganizationId;
|
||||||
|
|
||||||
@ApiModelProperty("收款单号")
|
@ApiModelProperty("收款单号")
|
||||||
@Excel(name = "收款单号")
|
@Excel(name = "收款单号")
|
||||||
@@ -107,22 +107,19 @@ public class TmsReceiptDTO extends BaseVOEntity{
|
|||||||
@Excel(name = "是否删除", readConverterExp = "删除标记:0-无状态,1-正常,2-已删除")
|
@Excel(name = "是否删除", readConverterExp = "删除标记:0-无状态,1-正常,2-已删除")
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "组织ID集合")
|
||||||
|
private List<Long> organizationIdList;
|
||||||
|
|
||||||
// @ApiModelProperty(name = "组织ID集合")
|
@ApiModelProperty(name = "权限菜单ID")
|
||||||
// @Excel(name = "组织ID集合")
|
private Long permissionMenuId;
|
||||||
// private List<Long> organizationIdList;
|
|
||||||
//
|
@ApiModelProperty("组织表id")
|
||||||
// @ApiModelProperty(name = "权限菜单ID")
|
@Excel(name = "组织表id")
|
||||||
// @Excel(name = "权限菜单ID")
|
private Long organizationId;
|
||||||
// private Long permissionMenuId;
|
|
||||||
//
|
@ApiModelProperty("组织名称")
|
||||||
// @ApiModelProperty("组织表id")
|
@Excel(name = "组织名称")
|
||||||
// @Excel(name = "组织表id")
|
private String organizationName;
|
||||||
// private Long organizationId;
|
|
||||||
//
|
|
||||||
// @ApiModelProperty("组织名称")
|
|
||||||
// @Excel(name = "组织名称")
|
|
||||||
// private String organizationName;
|
|
||||||
|
|
||||||
@ApiModelProperty("挂账原因")
|
@ApiModelProperty("挂账原因")
|
||||||
@Excel(name = "挂账原因")
|
@Excel(name = "挂账原因")
|
||||||
|
|||||||
+2
@@ -15,6 +15,8 @@ import com.linke.finance.domain.reconciliation.repository.po.FinacialReconciliat
|
|||||||
import com.linke.finance.infrastructure.util.UniqueKeyUtil;
|
import com.linke.finance.infrastructure.util.UniqueKeyUtil;
|
||||||
import com.linke.finance.interfaces.dto.InvoiceOrderDto;
|
import com.linke.finance.interfaces.dto.InvoiceOrderDto;
|
||||||
import com.mhd.common.core.domain.dto.BusinessDocumentDetaliDTO;
|
import com.mhd.common.core.domain.dto.BusinessDocumentDetaliDTO;
|
||||||
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
|
import com.mhd.system.api.model.LoginUser;
|
||||||
import com.mhd.common.core.domain.dto.EditPaymentMethodDTO;
|
import com.mhd.common.core.domain.dto.EditPaymentMethodDTO;
|
||||||
import com.mhd.common.log.annotation.Log;
|
import com.mhd.common.log.annotation.Log;
|
||||||
import com.mhd.common.log.enums.BusinessType;
|
import com.mhd.common.log.enums.BusinessType;
|
||||||
|
|||||||
+80
@@ -16,6 +16,8 @@ import com.mhd.common.core.utils.IgnoreNullUtil;
|
|||||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||||
import com.mhd.common.log.annotation.Log;
|
import com.mhd.common.log.annotation.Log;
|
||||||
import com.mhd.common.log.enums.BusinessType;
|
import com.mhd.common.log.enums.BusinessType;
|
||||||
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
|
import com.mhd.system.api.model.LoginUser;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -56,6 +58,39 @@ public class TmsReceiptApi extends BaseController{
|
|||||||
// TmsReceiptDO tmsReceiptDO = tmsReceiptAssembler.toDO(tmsReceiptDTO);
|
// TmsReceiptDO tmsReceiptDO = tmsReceiptAssembler.toDO(tmsReceiptDTO);
|
||||||
TmsReceiptDO tmsReceiptDO = new TmsReceiptDO();
|
TmsReceiptDO tmsReceiptDO = new TmsReceiptDO();
|
||||||
BeanUtils.copyProperties(tmsReceiptDTO, tmsReceiptDO);
|
BeanUtils.copyProperties(tmsReceiptDTO, tmsReceiptDO);
|
||||||
|
// 获取当前登录用户的组织信息,用于SQL中的数据隔离
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginOrgId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
// 保存前端传入的组织查询条件(如果有)
|
||||||
|
Long frontendOrgId = tmsReceiptDO.getOrganizationId();
|
||||||
|
Long frontendTopOrgId = tmsReceiptDO.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可查询全部组织数据;其他组织只能查询自己组织的数据
|
||||||
|
if (loginOrgId == null || !loginOrgId.equals(2827L)) {
|
||||||
|
// 其他组织:只能查询自己组织的数据,忽略前端传入的组织查询条件
|
||||||
|
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
Long orgId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
// 强制使用当前登录用户的组织信息,确保只能查询自己组织的数据
|
||||||
|
if (topOrgId != null) {
|
||||||
|
tmsReceiptDO.setTopOrganizationId(topOrgId);
|
||||||
|
}
|
||||||
|
if (orgId != null) {
|
||||||
|
tmsReceiptDO.setOrganizationId(orgId);
|
||||||
|
}
|
||||||
|
// 注意:organizationName 条件仍然可以使用,但会被 organizationId 条件限制,只能查询自己组织的
|
||||||
|
} else {
|
||||||
|
// 南光组织(organizationId = 2827):可以查询全部组织数据
|
||||||
|
// 如果前端传入了组织查询条件(organizationId、topOrganizationId或organizationName),则使用前端条件
|
||||||
|
// 如果前端没有传入任何组织查询条件,则不设置组织ID过滤,查询全部(但organization_name IS NOT NULL仍会生效)
|
||||||
|
if (frontendOrgId == null && frontendTopOrgId == null && (tmsReceiptDO.getOrganizationName() == null || tmsReceiptDO.getOrganizationName().isEmpty())) {
|
||||||
|
// 前端没有传入任何组织查询条件,清空组织ID过滤,查询全部组织数据
|
||||||
|
tmsReceiptDO.setTopOrganizationId(null);
|
||||||
|
tmsReceiptDO.setOrganizationId(null);
|
||||||
|
}
|
||||||
|
// 如果前端传入了组织查询条件,则保留使用前端条件(organizationId、topOrganizationId或organizationName)
|
||||||
|
}
|
||||||
|
}
|
||||||
startPage();
|
startPage();
|
||||||
List<TmsReceiptPO> list = tmsReceiptApplicationService.queryList(tmsReceiptDO);
|
List<TmsReceiptPO> list = tmsReceiptApplicationService.queryList(tmsReceiptDO);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
@@ -71,6 +106,22 @@ public class TmsReceiptApi extends BaseController{
|
|||||||
//转换实体
|
//转换实体
|
||||||
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
|
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
|
||||||
BeanUtils.copyProperties(receivingAccountDTO, receivingAccountDO);
|
BeanUtils.copyProperties(receivingAccountDTO, receivingAccountDO);
|
||||||
|
// 获取当前登录用户的组织信息,用于数据隔离
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可查询全部组织数据;其他组织只能查询自己组织的数据
|
||||||
|
if (organizationId == null || !organizationId.equals(2827L)) {
|
||||||
|
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
Long orgId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
if (topOrgId != null) {
|
||||||
|
receivingAccountDO.setTopOrganizationId(String.valueOf(topOrgId));
|
||||||
|
}
|
||||||
|
if (orgId != null) {
|
||||||
|
receivingAccountDO.setOrganizationId(String.valueOf(orgId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
startPage();
|
startPage();
|
||||||
List<ReceivingAccountPO> list = receivingAccountApplicationService.queryList(receivingAccountDO);
|
List<ReceivingAccountPO> list = receivingAccountApplicationService.queryList(receivingAccountDO);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
@@ -87,6 +138,18 @@ public class TmsReceiptApi extends BaseController{
|
|||||||
//转换实体
|
//转换实体
|
||||||
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
|
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
|
||||||
BeanUtils.copyProperties(receivingAccountDTO, receivingAccountDO);
|
BeanUtils.copyProperties(receivingAccountDTO, receivingAccountDO);
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
receivingAccountDO.setTopOrganizationId(String.valueOf(topOrganizationId));
|
||||||
|
}
|
||||||
|
if (organizationId != null) {
|
||||||
|
receivingAccountDO.setOrganizationId(String.valueOf(organizationId));
|
||||||
|
}
|
||||||
|
}
|
||||||
return toAjax(receivingAccountApplicationService.insert(receivingAccountDO));
|
return toAjax(receivingAccountApplicationService.insert(receivingAccountDO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,11 +161,28 @@ public class TmsReceiptApi extends BaseController{
|
|||||||
@PostMapping("/batchAddAccount")
|
@PostMapping("/batchAddAccount")
|
||||||
public AjaxResult batchAddAccount(@RequestBody List<ReceivingAccountDTO> receivingAccountDTOList)
|
public AjaxResult batchAddAccount(@RequestBody List<ReceivingAccountDTO> receivingAccountDTOList)
|
||||||
{
|
{
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
String topOrganizationId = null;
|
||||||
|
String organizationId = null;
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
Long orgId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
if (topOrgId != null) {
|
||||||
|
topOrganizationId = String.valueOf(topOrgId);
|
||||||
|
}
|
||||||
|
if (orgId != null) {
|
||||||
|
organizationId = String.valueOf(orgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
//转换实体
|
//转换实体
|
||||||
List<ReceivingAccountDO> receivingAccountDOList = new ArrayList<>();
|
List<ReceivingAccountDO> receivingAccountDOList = new ArrayList<>();
|
||||||
for (ReceivingAccountDTO dto : receivingAccountDTOList) {
|
for (ReceivingAccountDTO dto : receivingAccountDTOList) {
|
||||||
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
|
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
|
||||||
BeanUtils.copyProperties(dto, receivingAccountDO);
|
BeanUtils.copyProperties(dto, receivingAccountDO);
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
|
receivingAccountDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
receivingAccountDO.setOrganizationId(organizationId);
|
||||||
receivingAccountDOList.add(receivingAccountDO);
|
receivingAccountDOList.add(receivingAccountDO);
|
||||||
}
|
}
|
||||||
return toAjax(receivingAccountApplicationService.batchInsert(receivingAccountDOList));
|
return toAjax(receivingAccountApplicationService.batchInsert(receivingAccountDOList));
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="topOrganizationId" column="top_organization_id" />
|
||||||
|
<result property="organizationId" column="organization_id" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectReceivingAccountPo">
|
<sql id="selectReceivingAccountPo">
|
||||||
select id, account_name, account_information, del_flag, create_time, update_time
|
select id, account_name, account_information, del_flag, create_time, update_time, top_organization_id, organization_id
|
||||||
from receiving_account
|
from receiving_account
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -30,6 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="accountInformation != null and accountInformation != ''">
|
<if test="accountInformation != null and accountInformation != ''">
|
||||||
and account_information like concat('%', #{accountInformation}, '%')
|
and account_information like concat('%', #{accountInformation}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="topOrganizationId != null and topOrganizationId != ''">
|
||||||
|
and top_organization_id = #{topOrganizationId}
|
||||||
|
</if>
|
||||||
|
<if test="organizationId != null and organizationId != ''">
|
||||||
|
and organization_id = #{organizationId}
|
||||||
|
</if>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
@@ -47,6 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="delFlag != null">del_flag,</if>
|
<if test="delFlag != null">del_flag,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="topOrganizationId != null and topOrganizationId != ''">top_organization_id,</if>
|
||||||
|
<if test="organizationId != null and organizationId != ''">organization_id,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="accountName != null and accountName != ''">#{accountName},</if>
|
<if test="accountName != null and accountName != ''">#{accountName},</if>
|
||||||
@@ -54,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="delFlag != null">#{delFlag},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="topOrganizationId != null and topOrganizationId != ''">#{topOrganizationId},</if>
|
||||||
|
<if test="organizationId != null and organizationId != ''">#{organizationId},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -84,4 +96,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
update_time = now()
|
update_time = now()
|
||||||
where del_flag = 1
|
where del_flag = 1
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteByOrganization">
|
||||||
|
update receiving_account
|
||||||
|
set del_flag = 2,
|
||||||
|
update_time = now()
|
||||||
|
where del_flag = 1
|
||||||
|
<if test="topOrganizationId != null and topOrganizationId != ''">
|
||||||
|
and top_organization_id = #{topOrganizationId}
|
||||||
|
</if>
|
||||||
|
<if test="organizationId != null and organizationId != ''">
|
||||||
|
and organization_id = #{organizationId}
|
||||||
|
</if>
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateByName" column="update_by_name" />
|
<result property="updateByName" column="update_by_name" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="organizationId" column="organization_id" />
|
<result property="organizationId" column="organization_id" />
|
||||||
|
<result property="organizationName" column="organization_name" />
|
||||||
<result property="topOrganizationId" column="top_organization_id" />
|
<result property="topOrganizationId" column="top_organization_id" />
|
||||||
<result property="approvalNumber" column="approval_number" />
|
<result property="approvalNumber" column="approval_number" />
|
||||||
<result property="isInvoice" column="is_invoice" />
|
<result property="isInvoice" column="is_invoice" />
|
||||||
@@ -134,12 +135,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateByName != null and updateByName != ''">
|
<if test="updateByName != null and updateByName != ''">
|
||||||
and a.update_by_name like concat('%', #{updateByName}, '%')
|
and a.update_by_name like concat('%', #{updateByName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<!-- 组织ID过滤条件:如果设置了organizationId,则按组织ID精确匹配 -->
|
||||||
<if test="organizationId != null ">
|
<if test="organizationId != null ">
|
||||||
and a.organization_id = #{organizationId}
|
and a.organization_id = #{organizationId}
|
||||||
</if>
|
</if>
|
||||||
|
<!-- 一级组织ID过滤条件:如果设置了topOrganizationId,则按一级组织ID匹配 -->
|
||||||
<if test="topOrganizationId != null ">
|
<if test="topOrganizationId != null ">
|
||||||
and a.top_organization_id = #{topOrganizationId}
|
and a.top_organization_id = #{topOrganizationId}
|
||||||
</if>
|
</if>
|
||||||
|
<!-- 组织名称模糊查询条件:如果前端传入了组织名称,则按组织名称模糊匹配 -->
|
||||||
|
<if test="organizationName != null and organizationName != ''">
|
||||||
|
and a.organization_name LIKE CONCAT('%',#{organizationName},'%')
|
||||||
|
</if>
|
||||||
|
<!-- 当设置了组织相关查询条件时,确保organization_name不为null且不为空字符串 -->
|
||||||
|
<if test="organizationId != null or topOrganizationId != null or (organizationName != null and organizationName != '')">
|
||||||
|
and a.organization_name IS NOT NULL
|
||||||
|
and a.organization_name <> ''
|
||||||
|
and LENGTH(TRIM(a.organization_name)) > 0
|
||||||
|
</if>
|
||||||
<if test="collectionTimeStart != null and collectionTimeEnd != null">
|
<if test="collectionTimeStart != null and collectionTimeEnd != null">
|
||||||
AND (date_format(a.collection_time,'%Y-%m-%d') >= date_format(#{collectionTimeStart},'%Y-%m-%d')
|
AND (date_format(a.collection_time,'%Y-%m-%d') >= date_format(#{collectionTimeStart},'%Y-%m-%d')
|
||||||
and date_format(a.collection_time,'%Y-%m-%d') <![CDATA[<=]]> date_format(#{collectionTimeEnd},'%Y-%m-%d'))
|
and date_format(a.collection_time,'%Y-%m-%d') <![CDATA[<=]]> date_format(#{collectionTimeEnd},'%Y-%m-%d'))
|
||||||
|
|||||||
-4
@@ -45,8 +45,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="bankAccount" column="bank_account" />
|
<result property="bankAccount" column="bank_account" />
|
||||||
<result property="oilNumber" column="oil_number" />
|
<result property="oilNumber" column="oil_number" />
|
||||||
<result property="voucherImages" column="voucher_images" />
|
<result property="voucherImages" column="voucher_images" />
|
||||||
<result property="payChannel" column="pay_channel" />
|
|
||||||
<result property="payChannelName" column="pay_channel_name" />
|
|
||||||
|
|
||||||
<result property="kingdee" column="kingdee" />
|
<result property="kingdee" column="kingdee" />
|
||||||
<result property="kingdeeSubjectCode" column="kingdee_subject_code" />
|
<result property="kingdeeSubjectCode" column="kingdee_subject_code" />
|
||||||
@@ -95,8 +93,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
bank_account,
|
bank_account,
|
||||||
oil_number,
|
oil_number,
|
||||||
voucher_images,
|
voucher_images,
|
||||||
pay_channel,
|
|
||||||
pay_channel_name,
|
|
||||||
kingdee,
|
kingdee,
|
||||||
kingdee_subject_code,
|
kingdee_subject_code,
|
||||||
kingdee_subject_name,
|
kingdee_subject_name,
|
||||||
|
|||||||
@@ -97,6 +97,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
<if test="accountInformation != null and accountInformation != ''">
|
<if test="accountInformation != null and accountInformation != ''">
|
||||||
and account_information like concat('%', #{accountInformation}, '%')
|
and account_information like concat('%', #{accountInformation}, '%')
|
||||||
|
</if>
|
||||||
|
<!-- 无论什么情况,organization_name 都不能为空,也不能为空字符串 -->
|
||||||
|
and organization_name IS NOT NULL
|
||||||
|
and organization_name <> ''
|
||||||
|
and LENGTH(TRIM(organization_name)) > 0
|
||||||
|
<!-- 组织ID过滤条件:如果设置了organizationId,则按组织ID精确匹配 -->
|
||||||
|
<if test="organizationId != null ">
|
||||||
|
and organization_id = #{organizationId}
|
||||||
|
</if>
|
||||||
|
<!-- 一级组织ID过滤条件:如果设置了topOrganizationId,则按一级组织ID匹配 -->
|
||||||
|
<if test="topOrganizationId != null ">
|
||||||
|
and top_organization_id = #{topOrganizationId}
|
||||||
|
</if>
|
||||||
|
<!-- 组织名称模糊查询条件:如果前端传入了组织名称,则按组织名称模糊匹配 -->
|
||||||
|
<if test="organizationName != null and organizationName != ''">
|
||||||
|
and organization_name LIKE CONCAT('%',#{organizationName},'%')
|
||||||
</if>
|
</if>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</where>
|
</where>
|
||||||
|
|||||||
@@ -47,61 +47,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="organizationId" column="organization_id" />
|
<result property="organizationId" column="organization_id" />
|
||||||
<result property="topOrganizationId" column="top_organization_id" />
|
<result property="topOrganizationId" column="top_organization_id" />
|
||||||
|
<result property="organizationName" column="organization_name" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectVerificationVo">
|
<sql id="selectVerificationVo">
|
||||||
SELECT
|
SELECT
|
||||||
verification_id,
|
v.verification_id,
|
||||||
verification_status,
|
v.verification_status,
|
||||||
business_document_detali_id,
|
v.business_document_detali_id,
|
||||||
business_document_detali_number,
|
v.business_document_detali_number,
|
||||||
business_document_id,
|
v.business_document_id,
|
||||||
business_document_number,
|
v.business_document_number,
|
||||||
business_type,
|
v.business_type,
|
||||||
inner_number,
|
v.inner_number,
|
||||||
enter_account_time,
|
v.enter_account_time,
|
||||||
expense_item,
|
v.expense_item,
|
||||||
first_subject,
|
v.first_subject,
|
||||||
first_subject_name,
|
v.first_subject_name,
|
||||||
second_subject,
|
v.second_subject,
|
||||||
second_subject_name,
|
v.second_subject_name,
|
||||||
verification_money,
|
v.verification_money,
|
||||||
pay_id,
|
v.pay_id,
|
||||||
pay_person,
|
v.pay_person,
|
||||||
pay_channel,
|
v.pay_channel,
|
||||||
pay_channel_name,
|
v.pay_channel_name,
|
||||||
bank_number,
|
v.bank_number,
|
||||||
receipt_number,
|
v.receipt_number,
|
||||||
pay_remark,
|
v.pay_remark,
|
||||||
account_holder_name,
|
v.account_holder_name,
|
||||||
account_holder_bank,
|
v.account_holder_bank,
|
||||||
bank_account,
|
v.bank_account,
|
||||||
images,
|
v.images,
|
||||||
audit_remark,
|
v.audit_remark,
|
||||||
create_time,
|
v.create_time,
|
||||||
create_by,
|
v.create_by,
|
||||||
create_by_name,
|
v.create_by_name,
|
||||||
update_time,
|
v.update_time,
|
||||||
update_by,
|
v.update_by,
|
||||||
update_by_name,
|
v.update_by_name,
|
||||||
del_flag,
|
v.del_flag,
|
||||||
pay_way,
|
v.pay_way,
|
||||||
pay_way_name,
|
v.pay_way_name,
|
||||||
organization_id,
|
v.organization_id,
|
||||||
top_organization_id,
|
v.top_organization_id,
|
||||||
receivable_type,
|
v.receivable_type,
|
||||||
department_id,
|
v.department_id,
|
||||||
department_name,
|
v.department_name,
|
||||||
payee,
|
v.payee,
|
||||||
pay_type,
|
v.pay_type,
|
||||||
license_number,
|
v.license_number,
|
||||||
pay_id,
|
v.pay_name,
|
||||||
pay_name,
|
v.bill_remarks,
|
||||||
bill_remarks,
|
v.payment_method,
|
||||||
payment_method,
|
v.fuel_card_number,
|
||||||
fuel_card_number
|
v.organization_name
|
||||||
FROM
|
FROM
|
||||||
verification
|
verification v
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectVerificationOneList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
|
<select id="selectVerificationOneList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
|
||||||
@@ -343,9 +344,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectVerificationList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
|
<select id="selectVerificationList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
|
||||||
<include refid="selectVerificationVo"/>
|
<include refid="selectVerificationVo"/>
|
||||||
<where>
|
<where>
|
||||||
and del_flag = 1
|
and v.del_flag = 1
|
||||||
|
<!-- 组织查询条件:南光组织查所有,其他组织查自己 -->
|
||||||
|
<if test="organizationId != null">
|
||||||
|
<choose>
|
||||||
|
<!-- 南光组织判断:如果topOrganizationId为null,则为顶级组织(南光组织),查所有 -->
|
||||||
|
<when test="topOrganizationId == null">
|
||||||
|
<!-- 南光组织查所有数据,不添加组织过滤条件 -->
|
||||||
|
<!-- 如果organizationName为null,根据组织ID查询时不显示organizationName为null的数据 -->
|
||||||
|
<if test="organizationName == null or organizationName == ''">
|
||||||
|
AND v.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
<!-- 其他组织只查自己组织的数据 -->
|
||||||
|
AND v.organization_id = #{organizationId}
|
||||||
|
<!-- organizationName为null时,根据组织ID查询时不显示organizationName为null的数据 -->
|
||||||
|
<if test="organizationName == null or organizationName == ''">
|
||||||
|
AND v.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
|
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
|
||||||
AND business_document_number in
|
AND v.business_document_number in
|
||||||
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
|
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
|
||||||
#{waybill}
|
#{waybill}
|
||||||
</foreach>
|
</foreach>
|
||||||
@@ -369,55 +391,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<!-- )-->
|
<!-- )-->
|
||||||
<!-- </if>-->
|
<!-- </if>-->
|
||||||
<if test="enterAccountTimeStart != null">
|
<if test="enterAccountTimeStart != null">
|
||||||
AND date_format(create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
|
AND date_format(v.create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
|
||||||
</if>
|
</if>
|
||||||
<if test="enterAccountTimeEnd != null">
|
<if test="enterAccountTimeEnd != null">
|
||||||
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
|
AND date_format(v.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
|
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
|
||||||
AND date_format(cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
|
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
|
||||||
</if>
|
</if>
|
||||||
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
|
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
|
||||||
AND date_format(cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
|
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<if test="cancelAfterVerificationType != null"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>
|
<if test="cancelAfterVerificationType != null"> and v.cancel_after_verification_type = #{cancelAfterVerificationType}</if>
|
||||||
<if test="mailBranch != null"> and mail_branch = #{mailBranch}</if>
|
<if test="mailBranch != null"> and v.mail_branch = #{mailBranch}</if>
|
||||||
<if test="accountHolderBank != null and accountHolderBank != ''"> and account_holder_bank = #{accountHolderBank}</if>
|
<if test="accountHolderBank != null and accountHolderBank != ''"> and v.account_holder_bank = #{accountHolderBank}</if>
|
||||||
<if test="accountHolderName != null and accountHolderName != ''"> and account_holder_name = #{accountHolderName}</if>
|
<if test="accountHolderName != null and accountHolderName != ''"> and v.account_holder_name = #{accountHolderName}</if>
|
||||||
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
|
<if test="bankAccount != null and bankAccount != ''"> and v.bank_account = #{bankAccount}</if>
|
||||||
<if test="arriveBranch != null"> and arrive_branch = #{arriveBranch}</if>
|
<if test="arriveBranch != null"> and v.arrive_branch = #{arriveBranch}</if>
|
||||||
<if test="verificationType != null "> and verification_type = #{verificationType}</if>
|
<if test="verificationType != null "> and v.verification_type = #{verificationType}</if>
|
||||||
<if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and verification_status = #{verificationStatusOne}</if>
|
<if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and v.verification_status = #{verificationStatusOne}</if>
|
||||||
<if test="verificationStatus != null and verificationStatus == '5'.toString()"> and verification_status <![CDATA[<=]]> #{verificationStatus}</if>
|
<if test="verificationStatus != null and verificationStatus == '5'.toString()"> and v.verification_status <![CDATA[<=]]> #{verificationStatus}</if>
|
||||||
<if test="verificationStatus != null and verificationStatus == '6'.toString()"> and verification_status = #{verificationStatus}</if>
|
<if test="verificationStatus != null and verificationStatus == '6'.toString()"> and v.verification_status = #{verificationStatus}</if>
|
||||||
<if test="innerNumber != null and innerNumber != ''"> and inner_number like concat('%', #{innerNumber}, '%')</if>
|
<if test="innerNumber != null and innerNumber != ''"> and v.inner_number like concat('%', #{innerNumber}, '%')</if>
|
||||||
<if test="enterAccountTime != null "> and enter_account_time = #{enterAccountTime}</if>
|
<if test="enterAccountTime != null "> and v.enter_account_time = #{enterAccountTime}</if>
|
||||||
<if test="firstSubject != null and firstSubject != ''"> and first_subject = #{firstSubject}</if>
|
<if test="firstSubject != null and firstSubject != ''"> and v.first_subject = #{firstSubject}</if>
|
||||||
<if test="secondSubject != null and secondSubject != ''"> and second_subject = #{secondSubject}</if>
|
<if test="secondSubject != null and secondSubject != ''"> and v.second_subject = #{secondSubject}</if>
|
||||||
<if test="verificationMoney != null "> and verification_money = #{verificationMoney}</if>
|
<if test="verificationMoney != null "> and v.verification_money = #{verificationMoney}</if>
|
||||||
<if test="payPerson != null and payPerson != ''"> and pay_person = #{payPerson}</if>
|
<if test="payPerson != null and payPerson != ''"> and v.pay_person = #{payPerson}</if>
|
||||||
<if test="payChannel != null and payChannel != ''"> and pay_channel = #{payChannel}</if>
|
<if test="payChannel != null and payChannel != ''"> and v.pay_channel = #{payChannel}</if>
|
||||||
<if test="bankNumber != null and bankNumber != ''"> and bank_number = #{bankNumber}</if>
|
<if test="bankNumber != null and bankNumber != ''"> and v.bank_number = #{bankNumber}</if>
|
||||||
<if test="receiptNumber != null and receiptNumber != ''"> and receipt_number = #{receiptNumber}</if>
|
<if test="receiptNumber != null and receiptNumber != ''"> and v.receipt_number = #{receiptNumber}</if>
|
||||||
<if test="collectionRemark != null and collectionRemark != ''"> and collection_remark = #{collectionRemark}</if>
|
<if test="collectionRemark != null and collectionRemark != ''"> and v.collection_remark = #{collectionRemark}</if>
|
||||||
<if test="waybillId != null "> and waybill_id = #{waybillId}</if>
|
<if test="waybillId != null "> and v.waybill_id = #{waybillId}</if>
|
||||||
<if test="waybillNumber != null and waybillNumber != ''"> and waybill_number like concat('%', #{waybillNumber}, '%')</if>
|
<if test="waybillNumber != null and waybillNumber != ''"> and v.waybill_number like concat('%', #{waybillNumber}, '%')</if>
|
||||||
<if test="waybillRemark != null and waybillRemark != ''"> and waybill_remark = #{waybillRemark}</if>
|
<if test="waybillRemark != null and waybillRemark != ''"> and v.waybill_remark = #{waybillRemark}</if>
|
||||||
<if test="waybillSource != null and waybillSource != ''"> and waybill_source = #{waybillSource}</if>
|
<if test="waybillSource != null and waybillSource != ''"> and v.waybill_source = #{waybillSource}</if>
|
||||||
<if test="revenueExpensesNumber != null and revenueExpensesNumber != ''"> and revenue_expenses_number = #{revenueExpensesNumber}</if>
|
<if test="revenueExpensesNumber != null and revenueExpensesNumber != ''"> and v.revenue_expenses_number = #{revenueExpensesNumber}</if>
|
||||||
<if test="enterAccountId != null "> and enter_account_id = #{enterAccountId}</if>
|
<if test="enterAccountId != null "> and v.enter_account_id = #{enterAccountId}</if>
|
||||||
<if test="enterAccountName != null and enterAccountName != ''"> and enter_account_name like concat('%', #{enterAccountName}, '%')</if>
|
<if test="enterAccountName != null and enterAccountName != ''"> and v.enter_account_name like concat('%', #{enterAccountName}, '%')</if>
|
||||||
<if test="cancelAfterVerificationId != null "> and cancel_after_verification_id = #{cancelAfterVerificationId}</if>
|
<if test="cancelAfterVerificationId != null "> and v.cancel_after_verification_id = #{cancelAfterVerificationId}</if>
|
||||||
<if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>
|
<if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and v.cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>
|
||||||
<if test="cancelAfterVerificationTime != null "> and cancel_after_verification_time = #{cancelAfterVerificationTime}</if>
|
<if test="cancelAfterVerificationTime != null "> and v.cancel_after_verification_time = #{cancelAfterVerificationTime}</if>
|
||||||
<if test="createByName != null and createByName != ''"> and create_by_name like concat('%', #{createByName}, '%')</if>
|
<if test="createByName != null and createByName != ''"> and v.create_by_name like concat('%', #{createByName}, '%')</if>
|
||||||
<if test="updateByName != null and updateByName != ''"> and update_by_name like concat('%', #{updateByName}, '%')</if>
|
<if test="updateByName != null and updateByName != ''"> and v.update_by_name like concat('%', #{updateByName}, '%')</if>
|
||||||
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and verification_status in (1,2,3,4,5)</if>
|
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and v.verification_status in (1,2,3,4,5)</if>
|
||||||
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and verification_status = 6</if>
|
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and v.verification_status = 6</if>
|
||||||
<if test="inVerificationStatus != null"> and in_verification_status = #{inVerificationStatus}</if>
|
<if test="inVerificationStatus != null"> and v.in_verification_status = #{inVerificationStatus}</if>
|
||||||
<if test="uuidCode != null"> and uuid_code = #{uuidCode}</if>
|
<if test="uuidCode != null"> and v.uuid_code = #{uuidCode}</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by v.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectVerificationByVerificationId" parameterType="java.lang.Long" resultMap="VerificationResult">
|
<select id="selectVerificationByVerificationId" parameterType="java.lang.Long" resultMap="VerificationResult">
|
||||||
@@ -989,12 +1011,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
a.create_time DESC, a.verification_id DESC
|
a.create_time DESC, a.verification_id DESC
|
||||||
</select>
|
</select>
|
||||||
<select id="selectOutVerificationList" resultType="com.mhd.common.core.domain.po.VerificationPo">
|
<select id="selectOutVerificationList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
|
||||||
<include refid="selectVerificationVo"/>
|
<include refid="selectVerificationVo"/>
|
||||||
<where>
|
<where>
|
||||||
and del_flag = 1
|
and v.del_flag = 1
|
||||||
|
<!-- 组织查询条件:南光组织查所有,其他组织查自己 -->
|
||||||
|
<if test="organizationId != null">
|
||||||
|
<choose>
|
||||||
|
<!-- 南光组织判断:如果topOrganizationId为null,则为顶级组织(南光组织),查所有 -->
|
||||||
|
<when test="topOrganizationId == null">
|
||||||
|
<!-- 南光组织查所有数据,不添加组织过滤条件 -->
|
||||||
|
<!-- 如果organizationName为null,根据组织ID查询时不显示organizationName为null的数据 -->
|
||||||
|
<if test="organizationName == null or organizationName == ''">
|
||||||
|
AND v.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
<!-- 其他组织只查自己组织的数据 -->
|
||||||
|
AND v.organization_id = #{organizationId}
|
||||||
|
<!-- organizationName为null时,根据组织ID查询时不显示organizationName为null的数据 -->
|
||||||
|
<if test="organizationName == null or organizationName == ''">
|
||||||
|
AND v.organization_name IS NOT NULL
|
||||||
|
</if>
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
|
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
|
||||||
AND business_document_number in
|
AND v.business_document_number in
|
||||||
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
|
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
|
||||||
#{waybill}
|
#{waybill}
|
||||||
</foreach>
|
</foreach>
|
||||||
@@ -1018,50 +1061,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<!-- )-->
|
<!-- )-->
|
||||||
<!-- </if>-->
|
<!-- </if>-->
|
||||||
<if test="enterAccountTimeStart != null">
|
<if test="enterAccountTimeStart != null">
|
||||||
AND date_format(create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
|
AND date_format(v.create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
|
||||||
</if>
|
</if>
|
||||||
<if test="enterAccountTimeEnd != null">
|
<if test="enterAccountTimeEnd != null">
|
||||||
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
|
AND date_format(v.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="paymentMethod != null ">
|
<if test="paymentMethod != null ">
|
||||||
and payment_method = #{paymentMethod}
|
and v.payment_method = #{paymentMethod}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
|
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
|
||||||
AND date_format(cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
|
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
|
||||||
</if>
|
</if>
|
||||||
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
|
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
|
||||||
AND date_format(cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
|
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
|
||||||
</if>
|
</if>
|
||||||
<!-- <if test="cancelAfterVerificationType != null"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>-->
|
<!-- <if test="cancelAfterVerificationType != null"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>-->
|
||||||
<!-- <if test="mailBranch != null"> and mail_branch = #{mailBranch}</if>-->
|
<!-- <if test="mailBranch != null"> and mail_branch = #{mailBranch}</if>-->
|
||||||
<if test="accountHolderBank != null and accountHolderBank != ''"> and account_holder_bank = #{accountHolderBank}</if>
|
<if test="accountHolderBank != null and accountHolderBank != ''"> and v.account_holder_bank = #{accountHolderBank}</if>
|
||||||
<if test="businessDocumentDetaliNumber != null and businessDocumentDetaliNumber != ''"> and business_document_detali_number like concat('%', #{businessDocumentDetaliNumber}, '%')</if>
|
<if test="businessDocumentDetaliNumber != null and businessDocumentDetaliNumber != ''"> and v.business_document_detali_number like concat('%', #{businessDocumentDetaliNumber}, '%')</if>
|
||||||
<if test="accountHolderName != null and accountHolderName != ''"> and account_holder_name = #{accountHolderName}</if>
|
<if test="accountHolderName != null and accountHolderName != ''"> and v.account_holder_name = #{accountHolderName}</if>
|
||||||
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
|
<if test="bankAccount != null and bankAccount != ''"> and v.bank_account = #{bankAccount}</if>
|
||||||
<!-- <if test="arriveBranch != null"> and arrive_branch = #{arriveBranch}</if>-->
|
<!-- <if test="arriveBranch != null"> and arrive_branch = #{arriveBranch}</if>-->
|
||||||
<!-- <if test="verificationType != null "> and verification_type = #{verificationType}</if>-->
|
<!-- <if test="verificationType != null "> and verification_type = #{verificationType}</if>-->
|
||||||
<!-- <if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and verification_status = #{verificationStatusOne}</if>-->
|
<!-- <if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and verification_status = #{verificationStatusOne}</if>-->
|
||||||
<!-- <if test="verificationStatus != null and verificationStatus == '5'.toString()"> and verification_status <![CDATA[<=]]> #{verificationStatus}</if>-->
|
<!-- <if test="verificationStatus != null and verificationStatus == '5'.toString()"> and verification_status <![CDATA[<=]]> #{verificationStatus}</if>-->
|
||||||
<if test="verificationStatus != null "> and verification_status = #{verificationStatus}</if>
|
<if test="verificationStatus != null "> and v.verification_status = #{verificationStatus}</if>
|
||||||
<if test="businessType != null "> and business_type = #{businessType}</if>
|
<if test="businessType != null "> and v.business_type = #{businessType}</if>
|
||||||
<if test="innerNumber != null and innerNumber != ''"> and inner_number like concat('%', #{innerNumber}, '%')</if>
|
<if test="innerNumber != null and innerNumber != ''"> and v.inner_number like concat('%', #{innerNumber}, '%')</if>
|
||||||
<if test="businessDocumentNumber != null and businessDocumentNumber != ''"> and business_document_number = #{businessDocumentNumber} </if>
|
<if test="businessDocumentNumber != null and businessDocumentNumber != ''"> and v.business_document_number = #{businessDocumentNumber} </if>
|
||||||
<if test="expenseItem != null and expenseItem != ''"> and expense_item = #{expenseItem} </if>
|
<if test="expenseItem != null and expenseItem != ''"> and v.expense_item = #{expenseItem} </if>
|
||||||
<if test="enterAccountTime != null "> and enter_account_time = #{enterAccountTime}</if>
|
<if test="enterAccountTime != null "> and v.enter_account_time = #{enterAccountTime}</if>
|
||||||
<if test="firstSubject != null and firstSubject != ''"> and first_subject = #{firstSubject}</if>
|
<if test="firstSubject != null and firstSubject != ''"> and v.first_subject = #{firstSubject}</if>
|
||||||
<if test="secondSubject != null and secondSubject != ''"> and second_subject = #{secondSubject}</if>
|
<if test="secondSubject != null and secondSubject != ''"> and v.second_subject = #{secondSubject}</if>
|
||||||
<if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
|
<if test="payType != null and payType != ''"> and v.pay_type = #{payType}</if>
|
||||||
<if test="payee != null and payee != ''"> and payee like concat('%', #{payee}, '%')</if>
|
<if test="payee != null and payee != ''"> and v.payee like concat('%', #{payee}, '%')</if>
|
||||||
<if test="payName != null and payName != ''"> and pay_name like concat('%', #{payName}, '%')</if>
|
<if test="payName != null and payName != ''"> and v.pay_name like concat('%', #{payName}, '%')</if>
|
||||||
<if test="licenseNumber != null and licenseNumber != ''"> and license_number like concat('%', #{licenseNumber}, '%')</if>
|
<if test="licenseNumber != null and licenseNumber != ''"> and v.license_number like concat('%', #{licenseNumber}, '%')</if>
|
||||||
<if test="departmentName != null and departmentName != ''"> and department_name like concat('%', #{departmentName}, '%')</if>
|
<if test="departmentName != null and departmentName != ''"> and v.department_name like concat('%', #{departmentName}, '%')</if>
|
||||||
<if test="verificationMoney != null "> and verification_money = #{verificationMoney}</if>
|
<if test="verificationMoney != null "> and v.verification_money = #{verificationMoney}</if>
|
||||||
<if test="payPerson != null and payPerson != ''"> and pay_person = #{payPerson}</if>
|
<if test="payPerson != null and payPerson != ''"> and v.pay_person = #{payPerson}</if>
|
||||||
<if test="payChannel != null and payChannel != ''"> and pay_channel = #{payChannel}</if>
|
<if test="payChannel != null and payChannel != ''"> and v.pay_channel = #{payChannel}</if>
|
||||||
<if test="bankNumber != null and bankNumber != ''"> and bank_number = #{bankNumber}</if>
|
<if test="bankNumber != null and bankNumber != ''"> and v.bank_number = #{bankNumber}</if>
|
||||||
<if test="receiptNumber != null and receiptNumber != ''"> and receipt_number = #{receiptNumber}</if>
|
<if test="receiptNumber != null and receiptNumber != ''"> and v.receipt_number = #{receiptNumber}</if>
|
||||||
<!-- <if test="collectionRemark != null and collectionRemark != ''"> and collection_remark = #{collectionRemark}</if>-->
|
<!-- <if test="collectionRemark != null and collectionRemark != ''"> and collection_remark = #{collectionRemark}</if>-->
|
||||||
<!-- <if test="waybillId != null "> and waybill_id = #{waybillId}</if>-->
|
<!-- <if test="waybillId != null "> and waybill_id = #{waybillId}</if>-->
|
||||||
<!-- <if test="waybillNumber != null and waybillNumber != ''"> and waybill_number like concat('%', #{waybillNumber}, '%')</if>-->
|
<!-- <if test="waybillNumber != null and waybillNumber != ''"> and waybill_number like concat('%', #{waybillNumber}, '%')</if>-->
|
||||||
@@ -1073,12 +1116,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<!-- <if test="cancelAfterVerificationId != null "> and cancel_after_verification_id = #{cancelAfterVerificationId}</if>-->
|
<!-- <if test="cancelAfterVerificationId != null "> and cancel_after_verification_id = #{cancelAfterVerificationId}</if>-->
|
||||||
<!-- <if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>-->
|
<!-- <if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>-->
|
||||||
<!-- <if test="cancelAfterVerificationTime != null "> and cancel_after_verification_time = #{cancelAfterVerificationTime}</if>-->
|
<!-- <if test="cancelAfterVerificationTime != null "> and cancel_after_verification_time = #{cancelAfterVerificationTime}</if>-->
|
||||||
<if test="createByName != null and createByName != ''"> and create_by_name like concat('%', #{createByName}, '%')</if>
|
<if test="createByName != null and createByName != ''"> and v.create_by_name like concat('%', #{createByName}, '%')</if>
|
||||||
<if test="updateByName != null and updateByName != ''"> and update_by_name like concat('%', #{updateByName}, '%')</if>
|
<if test="updateByName != null and updateByName != ''"> and v.update_by_name like concat('%', #{updateByName}, '%')</if>
|
||||||
<!-- <if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and verification_status in (1,2,3,4,5)</if>-->
|
<!-- <if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and verification_status in (1,2,3,4,5)</if>-->
|
||||||
<!-- <if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and verification_status = 6</if>-->
|
<!-- <if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and verification_status = 6</if>-->
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by v.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -303,8 +303,9 @@ public class MenuApplicationService {
|
|||||||
Long tenantsId = organizationPo1.getTenantsId();
|
Long tenantsId = organizationPo1.getTenantsId();
|
||||||
OrganizationPo organizationPo = iOrganizationSvc.selectOrganizationById(organizationId);
|
OrganizationPo organizationPo = iOrganizationSvc.selectOrganizationById(organizationId);
|
||||||
List<MenuVo> menuVos = new ArrayList<>();
|
List<MenuVo> menuVos = new ArrayList<>();
|
||||||
//一级组织
|
//一级组织:organizationState == 1 表示是一级组织,或者 topOrganizationId == null/0
|
||||||
if(organizationPo.getParentOrganizationId() == 0){
|
if(organizationPo.getOrganizationState() != null && organizationPo.getOrganizationState() == 1
|
||||||
|
|| (organizationPo.getTopOrganizationId() == null || organizationPo.getTopOrganizationId() == 0)){
|
||||||
menuVos = menuDomainService.selectMenuIdListByTenantsId(organizationPo.getTenantsId(), 1);
|
menuVos = menuDomainService.selectMenuIdListByTenantsId(organizationPo.getTenantsId(), 1);
|
||||||
}else {
|
}else {
|
||||||
menuVos = menuDomainService.selectMenuIdListByOrganizationId(organizationId);
|
menuVos = menuDomainService.selectMenuIdListByOrganizationId(organizationId);
|
||||||
|
|||||||
+51
-1
@@ -100,6 +100,9 @@ public class OrganizationApplicationService {
|
|||||||
* @return 组织列表信息
|
* @return 组织列表信息
|
||||||
*/
|
*/
|
||||||
public List<OrganizationPo> selectOrganizationList(OrganizationPo organizationPo, DataPermission dataPermission) {
|
public List<OrganizationPo> selectOrganizationList(OrganizationPo organizationPo, DataPermission dataPermission) {
|
||||||
|
// 添加组织数据权限过滤
|
||||||
|
applyOrganizationDataPermission(organizationPo);
|
||||||
|
|
||||||
if(dataPermission != null){
|
if(dataPermission != null){
|
||||||
if(dataPermission.getOrganizationIdList() != null && dataPermission.getOrganizationIdList().size() > 0){
|
if(dataPermission.getOrganizationIdList() != null && dataPermission.getOrganizationIdList().size() > 0){
|
||||||
organizationPo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
organizationPo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
||||||
@@ -457,7 +460,7 @@ public class OrganizationApplicationService {
|
|||||||
if(parentOrganizationId != null && parentOrganizationId != 0L && CollectionUtil.isNotEmpty(menuIdList)){
|
if(parentOrganizationId != null && parentOrganizationId != 0L && CollectionUtil.isNotEmpty(menuIdList)){
|
||||||
//获取父级组织信息(一级组织拥有自己的菜单,非一级组织只拥有菜单权限)
|
//获取父级组织信息(一级组织拥有自己的菜单,非一级组织只拥有菜单权限)
|
||||||
OrganizationPo organizationPo = iOrganizationSvc.selectOrganizationById(parentOrganizationId);
|
OrganizationPo organizationPo = iOrganizationSvc.selectOrganizationById(parentOrganizationId);
|
||||||
if(organizationPo.getParentOrganizationId() == 0L){
|
if(organizationPo.getTopOrganizationId() == 0L){
|
||||||
//获取一级组织对应的所有菜单
|
//获取一级组织对应的所有菜单
|
||||||
List<Long> allByTenantsId = menuDomainService.getMenuIdByTenantsId(organizationPo.getTenantsId(),null);
|
List<Long> allByTenantsId = menuDomainService.getMenuIdByTenantsId(organizationPo.getTenantsId(),null);
|
||||||
if (CollectionUtil.isNotEmpty(allByTenantsId)){
|
if (CollectionUtil.isNotEmpty(allByTenantsId)){
|
||||||
@@ -634,4 +637,51 @@ public class OrganizationApplicationService {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermission(OrganizationPo organizationPo) {
|
||||||
|
try {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = organizationPo.getOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
organizationPo.setOrganizationId(frontendOrganizationId);
|
||||||
|
organizationPo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
organizationPo.setOrganizationId(null);
|
||||||
|
organizationPo.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
if (frontendOrganizationId != null && !frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
log.warn("组织列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
organizationPo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else if (frontendOrganizationId == null) {
|
||||||
|
organizationPo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
organizationPo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("应用组织数据权限过滤失败,将不进行组织过滤: {}", e.getMessage());
|
||||||
|
// 如果获取登录用户信息失败,不添加过滤条件,避免影响正常查询
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -21,6 +21,8 @@ public class OrganizationPo extends BaseVOEntity implements Serializable {
|
|||||||
private Long organizationId;
|
private Long organizationId;
|
||||||
@ApiModelProperty(name = "上级组织表ID")
|
@ApiModelProperty(name = "上级组织表ID")
|
||||||
private Long parentOrganizationId;
|
private Long parentOrganizationId;
|
||||||
|
@ApiModelProperty(name = "一级组织表ID")
|
||||||
|
private Long topOrganizationId;
|
||||||
@ApiModelProperty(name = "组织名称")
|
@ApiModelProperty(name = "组织名称")
|
||||||
private String organizationName;
|
private String organizationName;
|
||||||
@ApiModelProperty(name = "员工数量")
|
@ApiModelProperty(name = "员工数量")
|
||||||
|
|||||||
+204
-36
@@ -139,6 +139,20 @@ public class VehicleApplicationService {
|
|||||||
*/
|
*/
|
||||||
@NeedSetValueMethod
|
@NeedSetValueMethod
|
||||||
public List<VehiclePo> selectVehicleList(VehiclePo vehiclePo, DataPermission dataPermission) {
|
public List<VehiclePo> selectVehicleList(VehiclePo vehiclePo, DataPermission dataPermission) {
|
||||||
|
// 获取登录人信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("车辆列表查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return vehicleDomainService.selectVehicleList(vehiclePo);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
|
||||||
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
Long frontendOrganizationId = vehiclePo.getOrganizationId();
|
||||||
|
|
||||||
if (dataPermission != null) {
|
if (dataPermission != null) {
|
||||||
if (CollUtil.isNotEmpty(dataPermission.getOrganizationIdList())) {
|
if (CollUtil.isNotEmpty(dataPermission.getOrganizationIdList())) {
|
||||||
vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
||||||
@@ -147,13 +161,52 @@ public class VehicleApplicationService {
|
|||||||
vehiclePo.setCreateBy(dataPermission.getCreateBy());
|
vehiclePo.setCreateBy(dataPermission.getCreateBy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取登录人信息
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
// businessType == 2 时(司机),设置创建人过滤
|
||||||
if (loginUser.getUserPo().getBusinessType() == 2) {
|
if (userPo.getBusinessType() == 2) {
|
||||||
vehiclePo.setCreateBy(loginUser.getUserPo().getUserId());
|
vehiclePo.setCreateBy(userPo.getUserId());
|
||||||
vehiclePo.setOrganizationId(null);
|
|
||||||
vehiclePo.setOrganizationIdList(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationId(frontendOrganizationId);
|
||||||
|
vehiclePo.setTopOrganizationId(null);
|
||||||
|
vehiclePo.setOrganizationIdList(null);
|
||||||
|
} else {
|
||||||
|
vehiclePo.setOrganizationId(null);
|
||||||
|
vehiclePo.setTopOrganizationId(null);
|
||||||
|
vehiclePo.setOrganizationIdList(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置 organizationId,只查询当前组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
log.warn("车辆列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else {
|
||||||
|
vehiclePo.setOrganizationId(frontendOrganizationId);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(topOrganizationId);
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationIdList(Collections.singletonList(loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
vehiclePo.setOrganizationIdList(Collections.singletonList(loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//查询所有已经被绑定的车辆
|
//查询所有已经被绑定的车辆
|
||||||
// try {
|
// try {
|
||||||
// R<List<Long>> vehicleIdList = userServiceFeign.getBindListByUserId(loginUser.getUserPo().getUserId());
|
// R<List<Long>> vehicleIdList = userServiceFeign.getBindListByUserId(loginUser.getUserPo().getUserId());
|
||||||
@@ -193,6 +246,18 @@ public class VehicleApplicationService {
|
|||||||
*/
|
*/
|
||||||
@NeedSetValueMethod
|
@NeedSetValueMethod
|
||||||
public List<VehiclePo> getUnBindList(VehiclePo vehiclePo, DataPermission dataPermission) {
|
public List<VehiclePo> getUnBindList(VehiclePo vehiclePo, DataPermission dataPermission) {
|
||||||
|
// 获取登录人信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("未绑定车辆列表查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return vehicleDomainService.selectVehicleList(vehiclePo);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
Long frontendOrganizationId = vehiclePo.getOrganizationId();
|
||||||
|
|
||||||
if (dataPermission != null) {
|
if (dataPermission != null) {
|
||||||
if (CollUtil.isNotEmpty(dataPermission.getOrganizationIdList())) {
|
if (CollUtil.isNotEmpty(dataPermission.getOrganizationIdList())) {
|
||||||
vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
||||||
@@ -201,12 +266,35 @@ public class VehicleApplicationService {
|
|||||||
vehiclePo.setCreateBy(dataPermission.getCreateBy());
|
vehiclePo.setCreateBy(dataPermission.getCreateBy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取登录人信息
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
// businessType == 2 时(司机),设置创建人过滤
|
||||||
if (loginUser.getUserPo().getBusinessType() == 2) {
|
if (userPo.getBusinessType() == 2) {
|
||||||
vehiclePo.setCreateBy(loginUser.getUserPo().getUserId());
|
vehiclePo.setCreateBy(userPo.getUserId());
|
||||||
vehiclePo.setOrganizationId(null);
|
}
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationId(frontendOrganizationId);
|
||||||
|
} else {
|
||||||
|
vehiclePo.setOrganizationId(null);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(null);
|
||||||
vehiclePo.setOrganizationIdList(null);
|
vehiclePo.setOrganizationIdList(null);
|
||||||
|
} else {
|
||||||
|
// 其他组织:只查询当前组织的数据
|
||||||
|
if (frontendOrganizationId != null && !frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
log.warn("未绑定车辆列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else if (frontendOrganizationId == null) {
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(topOrganizationId);
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationIdList(Collections.singletonList(loginUserOrganizationId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//查询所有已经被绑定的车辆
|
//查询所有已经被绑定的车辆
|
||||||
try {
|
try {
|
||||||
@@ -247,12 +335,49 @@ public class VehicleApplicationService {
|
|||||||
*/
|
*/
|
||||||
@NeedSetValueMethod
|
@NeedSetValueMethod
|
||||||
public List<VehiclePo> selectBindVehicleList(VehiclePo vehiclePo, DataPermission dataPermission) {
|
public List<VehiclePo> selectBindVehicleList(VehiclePo vehiclePo, DataPermission dataPermission) {
|
||||||
|
// 获取登录人信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("绑定车辆列表查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return vehicleDomainService.selectVehicleList(vehiclePo);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
Long frontendOrganizationId = vehiclePo.getOrganizationId();
|
||||||
|
|
||||||
if (dataPermission != null) {
|
if (dataPermission != null) {
|
||||||
if (dataPermission.getOrganizationIdList() != null
|
if (dataPermission.getOrganizationIdList() != null
|
||||||
&& dataPermission.getOrganizationIdList().size() > 0) {
|
&& dataPermission.getOrganizationIdList().size() > 0) {
|
||||||
vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationId(frontendOrganizationId);
|
||||||
|
} else {
|
||||||
|
vehiclePo.setOrganizationId(null);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(null);
|
||||||
|
vehiclePo.setOrganizationIdList(null);
|
||||||
|
} else {
|
||||||
|
// 其他组织:只查询当前组织的数据
|
||||||
|
if (frontendOrganizationId != null && !frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
log.warn("绑定车辆列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else if (frontendOrganizationId == null) {
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(topOrganizationId);
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationIdList(Collections.singletonList(loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
}
|
||||||
List<VehiclePo> vehiclePos = vehicleDomainService.selectVehicleList(vehiclePo);
|
List<VehiclePo> vehiclePos = vehicleDomainService.selectVehicleList(vehiclePo);
|
||||||
for (VehiclePo po : vehiclePos) {
|
for (VehiclePo po : vehiclePos) {
|
||||||
Map<String, String> map = userServiceFeign.selectUserBindByVehicleId(po.getVehicleId());
|
Map<String, String> map = userServiceFeign.selectUserBindByVehicleId(po.getVehicleId());
|
||||||
@@ -269,24 +394,43 @@ public class VehicleApplicationService {
|
|||||||
*/
|
*/
|
||||||
@NeedSetValueMethod
|
@NeedSetValueMethod
|
||||||
public List<VehiclePo> selectStowageVehiclelist(VehiclePo vehiclePo) {
|
public List<VehiclePo> selectStowageVehiclelist(VehiclePo vehiclePo) {
|
||||||
// if(dataPermission != null){
|
// 获取登录人信息
|
||||||
// if(dataPermission.getOrganizationIdList() != null && dataPermission.getOrganizationIdList().size() > 0){
|
|
||||||
// vehiclePo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
|
||||||
// }
|
|
||||||
// if(dataPermission.getCreateBy() != null){
|
|
||||||
// vehiclePo.setCreateBy(dataPermission.getCreateBy());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//获取登录人信息
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser == null || loginUser.getUserPo() == null) {
|
||||||
|
log.warn("配载车辆列表查询 - 未获取到登录用户信息,跳过数据权限过滤");
|
||||||
|
return vehicleDomainService.selectStowageVehiclelist(vehiclePo);
|
||||||
|
}
|
||||||
|
|
||||||
UserPo userPo = loginUser.getUserPo();
|
UserPo userPo = loginUser.getUserPo();
|
||||||
|
Long loginUserOrganizationId = userPo.getOrganizationId();
|
||||||
|
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
Long frontendOrganizationId = vehiclePo.getOrganizationId();
|
||||||
|
|
||||||
if (ObjectUtil.equals(userPo.getUserAccountType(), 3)) {
|
if (ObjectUtil.equals(userPo.getUserAccountType(), 3)) {
|
||||||
vehiclePo.setUserAccountType(3);
|
vehiclePo.setUserAccountType(3);
|
||||||
vehiclePo.setTopOrganizationId(userPo.getTopOrganizationId());
|
|
||||||
} else {
|
|
||||||
vehiclePo.setTopOrganizationId(userPo.getTopOrganizationId());
|
|
||||||
vehiclePo.setOrganizationId(userPo.getOrganizationId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据权限:根据 organizationId 来设置查询权限
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
vehiclePo.setOrganizationId(frontendOrganizationId);
|
||||||
|
} else {
|
||||||
|
vehiclePo.setOrganizationId(null);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 其他组织:只查询当前组织的数据
|
||||||
|
if (frontendOrganizationId != null && !frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||||
|
log.warn("配载车辆列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||||
|
frontendOrganizationId, loginUserOrganizationId);
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
} else if (frontendOrganizationId == null) {
|
||||||
|
vehiclePo.setOrganizationId(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
vehiclePo.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
|
||||||
return vehicleDomainService.selectStowageVehiclelist(vehiclePo);
|
return vehicleDomainService.selectStowageVehiclelist(vehiclePo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,8 +729,18 @@ public class VehicleApplicationService {
|
|||||||
if (currentVehiclePo != null) {
|
if (currentVehiclePo != null) {
|
||||||
Vehicle vehicleForWlhy = new Vehicle(); // 使用领域对象
|
Vehicle vehicleForWlhy = new Vehicle(); // 使用领域对象
|
||||||
BeanUtils.copyProperties(currentVehiclePo, vehicleForWlhy);
|
BeanUtils.copyProperties(currentVehiclePo, vehicleForWlhy);
|
||||||
vehicleWlhyDomainService.addVehicleInfo(vehicleForWlhy, 1); // 2 代表某种类型或状态
|
vehicleForWlhy.setUserId(currentVehiclePo.getUserId());
|
||||||
vehiclePendingReviewPush(loginUser);
|
try {
|
||||||
|
vehicleWlhyDomainService.addVehicleInfo(vehicleForWlhy, 1); // 1 代表绑定类型
|
||||||
|
vehiclePendingReviewPush(loginUser);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
// 同步网货失败时,记录日志但不影响车辆保存
|
||||||
|
// 第一次新增时,用户信息可能还未同步到网货系统,导致失败
|
||||||
|
// 第二次新增时,用户信息已存在,可以成功同步
|
||||||
|
log.warn("同步网货信息失败,但不影响车辆保存: {}", e.getMessage());
|
||||||
|
// 如果业务要求必须同步成功,可以取消下面的注释,让异常抛出
|
||||||
|
// throw e;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("未能找到刚保存的车辆信息用于同步网货,VehicleId: {}", vehicle.getVehicleId());
|
log.warn("未能找到刚保存的车辆信息用于同步网货,VehicleId: {}", vehicle.getVehicleId());
|
||||||
}
|
}
|
||||||
@@ -607,11 +761,18 @@ public class VehicleApplicationService {
|
|||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
//当前组织id
|
//当前组织id
|
||||||
Long organizationId = 0L;
|
Long organizationId = 0L;
|
||||||
|
Long topOrganizationId = 0L;
|
||||||
String organizationName = "";
|
String organizationName = "";
|
||||||
if (loginUser != null) {
|
if (loginUser != null) {
|
||||||
if (loginUser.getUserPo() != null && loginUser.getUserPo().getOrganizationId() != null) {
|
UserPo userPo = loginUser.getUserPo();
|
||||||
organizationId = loginUser.getUserPo().getOrganizationId();
|
if (userPo != null) {
|
||||||
organizationName = loginUser.getUserPo().getOrganizationName();
|
if (userPo.getOrganizationId() != null) {
|
||||||
|
organizationId = userPo.getOrganizationId();
|
||||||
|
organizationName = userPo.getOrganizationName();
|
||||||
|
}
|
||||||
|
if (userPo.getTopOrganizationId() != null) {
|
||||||
|
topOrganizationId = userPo.getTopOrganizationId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserConfigSwitchPo userConfigSwitchPo = commonApplicationService.getUserConfigSwitch();
|
UserConfigSwitchPo userConfigSwitchPo = commonApplicationService.getUserConfigSwitch();
|
||||||
@@ -660,8 +821,10 @@ public class VehicleApplicationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置当前登录用户的组织信息
|
||||||
vehicle.setOrganizationId(organizationId);
|
vehicle.setOrganizationId(organizationId);
|
||||||
vehicle.setOrganizationName(organizationName);
|
vehicle.setOrganizationName(organizationName);
|
||||||
|
vehicle.setTopOrganizationId(topOrganizationId);
|
||||||
|
|
||||||
VehiclePo oldVehiclePo = null;
|
VehiclePo oldVehiclePo = null;
|
||||||
if (ObjectUtil.isNotNull(vehicle.getVehicleId())) {
|
if (ObjectUtil.isNotNull(vehicle.getVehicleId())) {
|
||||||
@@ -830,12 +993,8 @@ public class VehicleApplicationService {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// 6. 持久化操作 (统一的 insert 或 update)
|
// 6. 持久化操作 (统一的 insert 或 update)
|
||||||
|
// 注意:组织信息已在前面设置(第670-673行),这里不需要重复设置
|
||||||
if (ObjectUtil.isNull(vehicle.getVehicleId())) { // 新增
|
if (ObjectUtil.isNull(vehicle.getVehicleId())) { // 新增
|
||||||
if (loginUser != null) {
|
|
||||||
vehicle.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
vehicle.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
|
||||||
vehicle.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
|
||||||
}
|
|
||||||
vehicleDomainService.insertVehicle(vehicle);
|
vehicleDomainService.insertVehicle(vehicle);
|
||||||
} else {
|
} else {
|
||||||
// 确保 vehicleId 是从 DTO 传递过来的,并且 oldVehiclePo 已被正确加载
|
// 确保 vehicleId 是从 DTO 传递过来的,并且 oldVehiclePo 已被正确加载
|
||||||
@@ -875,8 +1034,17 @@ public class VehicleApplicationService {
|
|||||||
Vehicle vehicleForWlhy = new Vehicle(); // 使用领域对象
|
Vehicle vehicleForWlhy = new Vehicle(); // 使用领域对象
|
||||||
BeanUtils.copyProperties(currentVehiclePo, vehicleForWlhy);
|
BeanUtils.copyProperties(currentVehiclePo, vehicleForWlhy);
|
||||||
vehicleForWlhy.setUserId(currentVehiclePo.getUserId());
|
vehicleForWlhy.setUserId(currentVehiclePo.getUserId());
|
||||||
vehicleWlhyDomainService.addVehicleInfo(vehicleForWlhy, 1); // 2 代表某种类型或状态
|
try {
|
||||||
vehiclePendingReviewPush(loginUser);
|
vehicleWlhyDomainService.addVehicleInfo(vehicleForWlhy, 1); // 1 代表绑定类型
|
||||||
|
vehiclePendingReviewPush(loginUser);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
// 同步网货失败时,记录日志但不影响车辆保存
|
||||||
|
// 第一次新增时,用户信息可能还未同步到网货系统,导致失败
|
||||||
|
// 第二次新增时,用户信息已存在,可以成功同步
|
||||||
|
log.warn("同步网货信息失败,但不影响车辆保存: {}", e.getMessage());
|
||||||
|
// 如果业务要求必须同步成功,可以取消下面的注释,让异常抛出
|
||||||
|
// throw e;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("未能找到刚保存的车辆信息用于同步网货,VehicleId: {}", vehicle.getVehicleId());
|
log.warn("未能找到刚保存的车辆信息用于同步网货,VehicleId: {}", vehicle.getVehicleId());
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-3
@@ -22,6 +22,7 @@ import com.linke.transport.interfaces.dto.warehouse.inBoundOrder.InboundOrderDTO
|
|||||||
import com.linke.transport.interfaces.dto.warehouse.inBoundOrder.InboundOrderDTO.Create;
|
import com.linke.transport.interfaces.dto.warehouse.inBoundOrder.InboundOrderDTO.Create;
|
||||||
import com.mhd.common.core.utils.OrderSequence;
|
import com.mhd.common.core.utils.OrderSequence;
|
||||||
import com.mhd.common.security.utils.SecurityUtils;
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
|
import com.mhd.system.api.model.LoginUser;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -292,7 +293,7 @@ public class InboundOrderService extends ServiceImpl<InboundOrderMapper, Inbound
|
|||||||
* 构建查询条件(函数式封装)
|
* 构建查询条件(函数式封装)
|
||||||
*/
|
*/
|
||||||
private LambdaQueryWrapper<InboundOrder> buildQueryWrapper(InboundOrderDTO.Query queryDTO) {
|
private LambdaQueryWrapper<InboundOrder> buildQueryWrapper(InboundOrderDTO.Query queryDTO) {
|
||||||
return new LambdaQueryWrapper<InboundOrder>()
|
LambdaQueryWrapper<InboundOrder> wrapper = new LambdaQueryWrapper<InboundOrder>()
|
||||||
.like(StringUtils.hasText(queryDTO.getInboundOrderNo()),
|
.like(StringUtils.hasText(queryDTO.getInboundOrderNo()),
|
||||||
InboundOrder::getInboundOrderNo, queryDTO.getInboundOrderNo())
|
InboundOrder::getInboundOrderNo, queryDTO.getInboundOrderNo())
|
||||||
.eq(Objects.nonNull(queryDTO.getOwnerId()),
|
.eq(Objects.nonNull(queryDTO.getOwnerId()),
|
||||||
@@ -304,8 +305,44 @@ public class InboundOrderService extends ServiceImpl<InboundOrderMapper, Inbound
|
|||||||
.ge(Objects.nonNull(queryDTO.getInboundTimeStart()),
|
.ge(Objects.nonNull(queryDTO.getInboundTimeStart()),
|
||||||
InboundOrder::getInboundTime,queryDTO.getInboundTimeStart())
|
InboundOrder::getInboundTime,queryDTO.getInboundTimeStart())
|
||||||
.lt(Objects.nonNull(queryDTO.getInboundTimeEnd()),
|
.lt(Objects.nonNull(queryDTO.getInboundTimeEnd()),
|
||||||
InboundOrder::getInboundTime,queryDTO.getInboundTimeEnd())
|
InboundOrder::getInboundTime,queryDTO.getInboundTimeEnd());
|
||||||
.orderByDesc(InboundOrder::getInboundTime);
|
|
||||||
|
// 添加组织数据权限过滤
|
||||||
|
applyOrganizationDataPermission(wrapper);
|
||||||
|
|
||||||
|
return wrapper.orderByDesc(InboundOrder::getInboundTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤
|
||||||
|
* 通过关联Material表来过滤组织数据
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermission(LambdaQueryWrapper<InboundOrder> wrapper) {
|
||||||
|
try {
|
||||||
|
com.mhd.system.api.model.LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可以查询全部组织数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织:需要通过Material关联来过滤
|
||||||
|
// 由于InboundOrder没有直接的组织字段,需要通过明细关联Material来过滤
|
||||||
|
// 使用EXISTS子查询:只查询包含当前组织物料的入库单
|
||||||
|
wrapper.exists(String.format(
|
||||||
|
"SELECT 1 FROM inbound_order_detail iod " +
|
||||||
|
"INNER JOIN material m ON iod.material_id = m.id AND m.is_deleted = 0 " +
|
||||||
|
"WHERE iod.inbound_order_id = inbound_order.id " +
|
||||||
|
"AND iod.is_deleted = 0 " +
|
||||||
|
"AND m.organization_id = '%s'",
|
||||||
|
loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
// 如果是2827组织,不添加过滤条件,可以查询全部
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("应用组织数据权限过滤失败,将不进行组织过滤: {}", e.getMessage());
|
||||||
|
// 如果获取登录用户信息失败,不添加过滤条件,避免影响正常查询
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+54
-2
@@ -14,6 +14,7 @@ import com.linke.transport.domain.warehouse.material.repository.MaterialReposito
|
|||||||
import com.linke.transport.infrastructure.warehouse.inventory.persistence.InventoryMapper;
|
import com.linke.transport.infrastructure.warehouse.inventory.persistence.InventoryMapper;
|
||||||
import com.linke.transport.interfaces.dto.warehouse.inventory.InventoryDTO;
|
import com.linke.transport.interfaces.dto.warehouse.inventory.InventoryDTO;
|
||||||
import com.mhd.common.security.utils.SecurityUtils;
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
|
import com.mhd.system.api.model.LoginUser;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@@ -50,12 +51,63 @@ public class InventoryService extends ServiceImpl<InventoryMapper, Inventory> {
|
|||||||
// 1. 创建分页请求对象 (注意泛型是 VO)
|
// 1. 创建分页请求对象 (注意泛型是 VO)
|
||||||
Page<InventoryVO> page = new Page<>(queryDTO.getPageNo(), queryDTO.getPageSize());
|
Page<InventoryVO> page = new Page<>(queryDTO.getPageNo(), queryDTO.getPageSize());
|
||||||
|
|
||||||
// 2. 调用 Mapper 的自定义分页查询方法 (该方法执行 JOIN)
|
// 2. 应用组织数据权限过滤(在XML中通过Material表的organizationId过滤)
|
||||||
|
applyOrganizationDataPermission(queryDTO);
|
||||||
|
|
||||||
|
// 3. 调用 Mapper 的自定义分页查询方法 (该方法执行 JOIN)
|
||||||
return inventoryMapper.findInventoryList(page, queryDTO);
|
return inventoryMapper.findInventoryList(page, queryDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤
|
||||||
|
* 设置organizationId到queryDTO中,供XML使用
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermission(InventoryDTO.Query queryDTO) {
|
||||||
|
try {
|
||||||
|
com.mhd.system.api.model.LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可以查询全部组织数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 设置organizationId到queryDTO中,供XML使用
|
||||||
|
// 注意:需要在InventoryDTO.Query中添加organizationId字段
|
||||||
|
// 由于Material的organizationId是String类型,需要转换为String
|
||||||
|
if (queryDTO.getOrganizationId() == null) {
|
||||||
|
queryDTO.setOrganizationId(String.valueOf(loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果是2827组织,不设置organizationId,可以查询全部
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("应用组织数据权限过滤失败,将不进行组织过滤: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<InventoryVO> listAllInventory(Long ownerId,String machineSerialNo) {
|
public List<InventoryVO> listAllInventory(Long ownerId,String machineSerialNo) {
|
||||||
return inventoryMapper.findAllInventoryList(ownerId,machineSerialNo);
|
// 应用组织数据权限过滤
|
||||||
|
String organizationId = getOrganizationIdForFilter();
|
||||||
|
return inventoryMapper.findAllInventoryList(ownerId, machineSerialNo, organizationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用于过滤的组织ID(String类型,因为Material表的organizationId是String)
|
||||||
|
* @return 如果不是2827组织,返回组织ID字符串;如果是2827,返回null(可查全部)
|
||||||
|
*/
|
||||||
|
private String getOrganizationIdForFilter() {
|
||||||
|
try {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
return String.valueOf(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("获取组织ID失败: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
return null; // 2827组织或获取失败时返回null,可查全部
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+34
-2
@@ -51,8 +51,12 @@ public class InventoryLedgerService extends ServiceImpl<InventoryLedgerMapper, I
|
|||||||
.ge(Objects.nonNull(query.getEventTimeStart()),
|
.ge(Objects.nonNull(query.getEventTimeStart()),
|
||||||
InventoryLedger::getEventTime,query.getEventTimeStart())
|
InventoryLedger::getEventTime,query.getEventTimeStart())
|
||||||
.lt(Objects.nonNull(query.getEventTimeEnd()),
|
.lt(Objects.nonNull(query.getEventTimeEnd()),
|
||||||
InventoryLedger::getEventTime,query.getEventTimeEnd())
|
InventoryLedger::getEventTime,query.getEventTimeEnd());
|
||||||
.orderByDesc(InventoryLedger :: getId);
|
|
||||||
|
// 添加组织数据权限过滤
|
||||||
|
applyOrganizationDataPermission(wrapper);
|
||||||
|
|
||||||
|
wrapper.orderByDesc(InventoryLedger :: getId);
|
||||||
|
|
||||||
return this.page(new Page<>(query.getPageNo(), query.getPageSize()), wrapper)
|
return this.page(new Page<>(query.getPageNo(), query.getPageSize()), wrapper)
|
||||||
.convert(item -> {
|
.convert(item -> {
|
||||||
@@ -62,6 +66,34 @@ public class InventoryLedgerService extends ServiceImpl<InventoryLedgerMapper, I
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤
|
||||||
|
* 通过关联Material表来过滤组织数据
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermission(LambdaQueryWrapper<InventoryLedger> wrapper) {
|
||||||
|
try {
|
||||||
|
com.mhd.system.api.model.LoginUser loginUser = com.mhd.common.security.utils.SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可以查询全部组织数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织:需要通过Material关联来过滤
|
||||||
|
// 由于InventoryLedger表中有materialId字段,我们通过EXISTS子查询关联Material来过滤
|
||||||
|
wrapper.exists(String.format(
|
||||||
|
"SELECT 1 FROM material m " +
|
||||||
|
"WHERE m.id = inventory_ledger.material_id " +
|
||||||
|
"AND m.organization_id = '%s' AND m.is_deleted = 0",
|
||||||
|
loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
// 如果是2827组织,不添加过滤条件,可以查询全部
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 如果获取登录用户信息失败,不添加过滤条件,避免影响正常查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据货主ID更新货主名称
|
* 根据货主ID更新货主名称
|
||||||
* @param ownerId 货主ID
|
* @param ownerId 货主ID
|
||||||
|
|||||||
+2
@@ -59,4 +59,6 @@ public class CreateMaterialCommand {
|
|||||||
private String topOrganizationId;
|
private String topOrganizationId;
|
||||||
/**组织相关*/
|
/**组织相关*/
|
||||||
private String organizationId;
|
private String organizationId;
|
||||||
|
/**组织相关*/
|
||||||
|
private String organizationName;
|
||||||
}
|
}
|
||||||
+2
-2
@@ -41,7 +41,7 @@ public class MaterialCommandService {
|
|||||||
command.getWeight(),
|
command.getWeight(),
|
||||||
command.getMaterialVolume(),
|
command.getMaterialVolume(),
|
||||||
command.getMaterialContent(),
|
command.getMaterialContent(),
|
||||||
command.getRemark(),command.getTopOrganizationId(),command.getOrganizationId(),
|
command.getRemark(),command.getTopOrganizationId(),command.getOrganizationId(),command.getOrganizationName(),
|
||||||
codeGenerator
|
codeGenerator
|
||||||
);
|
);
|
||||||
return materialRepository.save(material).getId();
|
return materialRepository.save(material).getId();
|
||||||
@@ -67,7 +67,7 @@ public class MaterialCommandService {
|
|||||||
command.getWeight(),
|
command.getWeight(),
|
||||||
command.getMaterialVolume(),
|
command.getMaterialVolume(),
|
||||||
command.getMaterialContent(),
|
command.getMaterialContent(),
|
||||||
command.getRemark(),command.getTopOrganizationId(),command.getOrganizationId()
|
command.getRemark(),command.getTopOrganizationId(),command.getOrganizationId(),command.getOrganizationName()
|
||||||
);
|
);
|
||||||
|
|
||||||
materialRepository.update(material);
|
materialRepository.update(material);
|
||||||
|
|||||||
+2
@@ -51,4 +51,6 @@ public class UpdateMaterialCommand {
|
|||||||
private String topOrganizationId;
|
private String topOrganizationId;
|
||||||
/**组织相关*/
|
/**组织相关*/
|
||||||
private String organizationId;
|
private String organizationId;
|
||||||
|
/**组织相关*/
|
||||||
|
private String organizationName;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -34,4 +34,10 @@ public class MaterialQueryCommand {
|
|||||||
private BigDecimal materialVolume;
|
private BigDecimal materialVolume;
|
||||||
@ApiModelProperty(value = "物料内容")
|
@ApiModelProperty(value = "物料内容")
|
||||||
private String materialContent;
|
private String materialContent;
|
||||||
|
@ApiModelProperty(value = "组织ID")
|
||||||
|
private String organizationId;
|
||||||
|
@ApiModelProperty(value = "组织名称")
|
||||||
|
private String organizationName;
|
||||||
|
@ApiModelProperty(value = "一级组织ID")
|
||||||
|
private String topOrganizationId;
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-4
@@ -5,6 +5,9 @@ import com.linke.transport.application.service.warehouse.material.vo.MaterialVO;
|
|||||||
import com.linke.transport.domain.warehouse.material.exception.MaterialDomainException;
|
import com.linke.transport.domain.warehouse.material.exception.MaterialDomainException;
|
||||||
import com.linke.transport.domain.warehouse.material.repository.MaterialRepository;
|
import com.linke.transport.domain.warehouse.material.repository.MaterialRepository;
|
||||||
import com.linke.transport.infrastructure.warehouse.material.converter.MaterialConverter;
|
import com.linke.transport.infrastructure.warehouse.material.converter.MaterialConverter;
|
||||||
|
import com.mhd.common.core.utils.StringUtils;
|
||||||
|
import com.mhd.system.api.model.LoginUser;
|
||||||
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -20,15 +23,79 @@ public class MaterialQueryService {
|
|||||||
* 分页查询物料
|
* 分页查询物料
|
||||||
*/
|
*/
|
||||||
public IPage<MaterialVO> queryMaterials(MaterialQueryCommand param) {
|
public IPage<MaterialVO> queryMaterials(MaterialQueryCommand param) {
|
||||||
return materialRepository.search(
|
// 先保存前端传递的 organizationId(如果存在)
|
||||||
|
String frontendOrganizationId = param.getOrganizationId();
|
||||||
|
|
||||||
|
// 获取当前登录用户的组织信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
Long loginUserOrganizationId = null;
|
||||||
|
Long topOrganizationId = null;
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
// 如果前端传递了 organizationId,使用前端传递的值进行过滤(包括2827)
|
||||||
|
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
if (StringUtils.isNotBlank(frontendOrganizationId)) {
|
||||||
|
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||||
|
param.setOrganizationId(frontendOrganizationId);
|
||||||
|
param.setTopOrganizationId(null);
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
param.setOrganizationId(null);
|
||||||
|
param.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 其他组织只能查询自己组织的数据,不能查询其他组织(包括南光)的数据
|
||||||
|
// 如果其他组织尝试查询南光(organizationId=2827)的数据,返回空数据
|
||||||
|
if (StringUtils.isNotBlank(frontendOrganizationId)) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if ("2827".equals(frontendOrganizationId)) {
|
||||||
|
// 其他组织尝试查询南光的数据,设置一个不存在的 organizationId,返回空数据
|
||||||
|
param.setOrganizationId("-1");
|
||||||
|
param.setTopOrganizationId(null);
|
||||||
|
} else if (!frontendOrganizationId.equals(String.valueOf(loginUserOrganizationId))) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
param.setOrganizationId(String.valueOf(loginUserOrganizationId));
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
param.setTopOrganizationId(String.valueOf(topOrganizationId));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
param.setOrganizationId(frontendOrganizationId);
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
param.setTopOrganizationId(String.valueOf(topOrganizationId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
param.setOrganizationId(String.valueOf(loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
if (topOrganizationId != null) {
|
||||||
|
param.setTopOrganizationId(String.valueOf(topOrganizationId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return materialRepository.search(
|
||||||
param.getShipper(),
|
param.getShipper(),
|
||||||
param.getCategory(),
|
param.getCategory(),
|
||||||
param.getName(),
|
param.getName(),
|
||||||
param.getModel(),
|
param.getModel(),
|
||||||
param.getMaterialCode(),
|
param.getMaterialCode(),
|
||||||
param.getCodeManaged(),
|
param.getCodeManaged(),
|
||||||
param.getRemark(),
|
param.getRemark(),
|
||||||
param.getMaterialContent(),
|
param.getMaterialContent(),
|
||||||
|
param.getOrganizationId(),
|
||||||
|
param.getOrganizationName(),
|
||||||
|
param.getTopOrganizationId(),
|
||||||
param.getPageNo(),
|
param.getPageNo(),
|
||||||
param.getPageSize()
|
param.getPageSize()
|
||||||
).convert(MaterialConverter :: convertToVO);
|
).convert(MaterialConverter :: convertToVO);
|
||||||
@@ -51,7 +118,32 @@ public class MaterialQueryService {
|
|||||||
* @return 所有材料的列表,以MaterialVO形式表示
|
* @return 所有材料的列表,以MaterialVO形式表示
|
||||||
*/
|
*/
|
||||||
public List<MaterialVO> getAllMaterials(Long ownerId) {
|
public List<MaterialVO> getAllMaterials(Long ownerId) {
|
||||||
return materialRepository.findAllMaterials(ownerId)
|
// 获取当前登录用户的组织信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
String organizationId = null;
|
||||||
|
String topOrganizationId = null;
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
|
||||||
|
// 数据权限:根据organizationId来设置查询权限
|
||||||
|
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||||
|
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 南光组织(organizationId=2827):不设置组织过滤条件,可以查询所有组织的数据
|
||||||
|
organizationId = null;
|
||||||
|
topOrganizationId = null;
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
if (loginUserOrganizationId != null) {
|
||||||
|
organizationId = String.valueOf(loginUserOrganizationId);
|
||||||
|
}
|
||||||
|
if (topOrgId != null) {
|
||||||
|
topOrganizationId = String.valueOf(topOrgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return materialRepository.findAllMaterials(ownerId, organizationId, null, topOrganizationId)
|
||||||
.stream()
|
.stream()
|
||||||
.map(MaterialConverter :: convertToVO)
|
.map(MaterialConverter :: convertToVO)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
+6
@@ -53,4 +53,10 @@ public class MaterialVO{
|
|||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
@ApiModelProperty("组织ID")
|
||||||
|
private String organizationId;
|
||||||
|
@ApiModelProperty("组织名称")
|
||||||
|
private String organizationName;
|
||||||
|
@ApiModelProperty("一级组织ID")
|
||||||
|
private String topOrganizationId;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-4
@@ -21,6 +21,7 @@ import com.linke.transport.interfaces.dto.warehouse.outBoundOrder.OutboundOrderD
|
|||||||
import com.linke.transport.interfaces.dto.warehouse.outBoundOrder.OutboundOrderDTO.Create;
|
import com.linke.transport.interfaces.dto.warehouse.outBoundOrder.OutboundOrderDTO.Create;
|
||||||
import com.mhd.common.core.utils.OrderSequence;
|
import com.mhd.common.core.utils.OrderSequence;
|
||||||
import com.mhd.common.security.utils.SecurityUtils;
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
|
import com.mhd.system.api.model.LoginUser;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -311,7 +312,7 @@ public class OutboundOrderService extends ServiceImpl<OutboundOrderMapper, Outbo
|
|||||||
* 构建出库列表查询条件
|
* 构建出库列表查询条件
|
||||||
*/
|
*/
|
||||||
private LambdaQueryWrapper<OutboundOrder> buildListQueryWrapper(OutboundOrderDTO.Query queryDTO) {
|
private LambdaQueryWrapper<OutboundOrder> buildListQueryWrapper(OutboundOrderDTO.Query queryDTO) {
|
||||||
return new LambdaQueryWrapper<OutboundOrder>()
|
LambdaQueryWrapper<OutboundOrder> wrapper = new LambdaQueryWrapper<OutboundOrder>()
|
||||||
.like(StringUtils.hasText(queryDTO.getOutboundOrderNo()),
|
.like(StringUtils.hasText(queryDTO.getOutboundOrderNo()),
|
||||||
OutboundOrder::getOutboundOrderNo, queryDTO.getOutboundOrderNo())
|
OutboundOrder::getOutboundOrderNo, queryDTO.getOutboundOrderNo())
|
||||||
.eq(Objects.nonNull(queryDTO.getOwnerId()),
|
.eq(Objects.nonNull(queryDTO.getOwnerId()),
|
||||||
@@ -323,9 +324,44 @@ public class OutboundOrderService extends ServiceImpl<OutboundOrderMapper, Outbo
|
|||||||
.ge(Objects.nonNull(queryDTO.getOutboundTimeStart()),
|
.ge(Objects.nonNull(queryDTO.getOutboundTimeStart()),
|
||||||
OutboundOrder::getOutboundTime,queryDTO.getOutboundTimeStart())
|
OutboundOrder::getOutboundTime,queryDTO.getOutboundTimeStart())
|
||||||
.lt(Objects.nonNull(queryDTO.getOutboundTimeEnd()),
|
.lt(Objects.nonNull(queryDTO.getOutboundTimeEnd()),
|
||||||
OutboundOrder::getOutboundTime,queryDTO.getOutboundTimeEnd())
|
OutboundOrder::getOutboundTime,queryDTO.getOutboundTimeEnd());
|
||||||
// 添加时间等其他查询条件
|
|
||||||
.orderByDesc(OutboundOrder::getOutboundTime); // 按出库时间降序
|
// 添加组织数据权限过滤
|
||||||
|
applyOrganizationDataPermission(wrapper);
|
||||||
|
|
||||||
|
return wrapper.orderByDesc(OutboundOrder::getOutboundTime); // 按出库时间降序
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用组织数据权限过滤
|
||||||
|
* 通过关联Material表来过滤组织数据
|
||||||
|
*/
|
||||||
|
private void applyOrganizationDataPermission(LambdaQueryWrapper<OutboundOrder> wrapper) {
|
||||||
|
try {
|
||||||
|
com.mhd.system.api.model.LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
|
||||||
|
// 如果当前登录用户的organizationId为2827(南光组织),可以查询全部组织数据
|
||||||
|
// 其他组织只能查询自己组织的数据
|
||||||
|
if (loginUserOrganizationId != null && !loginUserOrganizationId.equals(2827L)) {
|
||||||
|
// 其他组织:需要通过Material关联来过滤
|
||||||
|
// 由于OutboundOrder没有直接的组织字段,需要通过明细关联Material来过滤
|
||||||
|
// 使用EXISTS子查询:只查询包含当前组织物料的出库单
|
||||||
|
wrapper.exists(String.format(
|
||||||
|
"SELECT 1 FROM outbound_order_detail ood " +
|
||||||
|
"INNER JOIN material m ON ood.material_id = m.id AND m.is_deleted = 0 " +
|
||||||
|
"WHERE ood.outbound_order_id = outbound_order.id " +
|
||||||
|
"AND ood.is_deleted = 0 " +
|
||||||
|
"AND m.organization_id = '%s'",
|
||||||
|
loginUserOrganizationId));
|
||||||
|
}
|
||||||
|
// 如果是2827组织,不添加过滤条件,可以查询全部
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("应用组织数据权限过滤失败,将不进行组织过滤: {}", e.getMessage());
|
||||||
|
// 如果获取登录用户信息失败,不添加过滤条件,避免影响正常查询
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+11
-3
@@ -243,9 +243,17 @@ public class VehicleWlhyDomainService
|
|||||||
tmsVehicleDTO.setDrivingPermitExpDate(vehicle.getVehicleCheckoutPeriodValidity());
|
tmsVehicleDTO.setDrivingPermitExpDate(vehicle.getVehicleCheckoutPeriodValidity());
|
||||||
tmsVehicleDTO.setDrivingPermitNumber(vehicle.getVehicleFileNumber());
|
tmsVehicleDTO.setDrivingPermitNumber(vehicle.getVehicleFileNumber());
|
||||||
tmsVehicleDTO.setTransportPermitNumber(vehicle.getRoadTransportCertificateNo());
|
tmsVehicleDTO.setTransportPermitNumber(vehicle.getRoadTransportCertificateNo());
|
||||||
tmsVehicleDTO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
// 优先使用 vehicle 对象中保存的组织信息,确保与数据库中的组织ID一致
|
||||||
tmsVehicleDTO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
// 如果 vehicle 中没有组织信息,则使用当前登录用户的组织信息作为后备
|
||||||
tmsVehicleDTO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
if (vehicle.getOrganizationId() != null) {
|
||||||
|
tmsVehicleDTO.setOrganizationId(vehicle.getOrganizationId());
|
||||||
|
tmsVehicleDTO.setOrganizationName(vehicle.getOrganizationName());
|
||||||
|
tmsVehicleDTO.setTopOrganizationId(vehicle.getTopOrganizationId());
|
||||||
|
} else if (loginUser.getUserPo() != null) {
|
||||||
|
tmsVehicleDTO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
tmsVehicleDTO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||||
|
tmsVehicleDTO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
|
}
|
||||||
if (vehicle.getUseStatus() == 2){
|
if (vehicle.getUseStatus() == 2){
|
||||||
tmsVehicleDTO.setBlacklistStatus(1);
|
tmsVehicleDTO.setBlacklistStatus(1);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
+8
-4
@@ -37,6 +37,8 @@ public class Material {
|
|||||||
private String topOrganizationId;
|
private String topOrganizationId;
|
||||||
/**组织相关*/
|
/**组织相关*/
|
||||||
private String organizationId;
|
private String organizationId;
|
||||||
|
/**组织相关*/
|
||||||
|
private String organizationName;
|
||||||
|
|
||||||
|
|
||||||
// 私有构造方法
|
// 私有构造方法
|
||||||
@@ -51,7 +53,7 @@ public class Material {
|
|||||||
BigDecimal weight,
|
BigDecimal weight,
|
||||||
BigDecimal materialVolume,
|
BigDecimal materialVolume,
|
||||||
String materialContent,
|
String materialContent,
|
||||||
String remark,String topOrganizationId,String organizationId ) {
|
String remark,String topOrganizationId,String organizationId,String organizationName ) {
|
||||||
validateRequiredFields( category, name, unit);
|
validateRequiredFields( category, name, unit);
|
||||||
this.ownerId = ownerId;
|
this.ownerId = ownerId;
|
||||||
this.shipper = shipper;
|
this.shipper = shipper;
|
||||||
@@ -69,6 +71,7 @@ public class Material {
|
|||||||
this.updateTime = LocalDateTime.now();
|
this.updateTime = LocalDateTime.now();
|
||||||
this.topOrganizationId = topOrganizationId;
|
this.topOrganizationId = topOrganizationId;
|
||||||
this.organizationId = organizationId;
|
this.organizationId = organizationId;
|
||||||
|
this.organizationName = organizationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,11 +87,11 @@ public class Material {
|
|||||||
BigDecimal weight,
|
BigDecimal weight,
|
||||||
BigDecimal materialVolume,
|
BigDecimal materialVolume,
|
||||||
String materialContent,
|
String materialContent,
|
||||||
String remark,String topOrganizationId,String organizationId,
|
String remark,String topOrganizationId,String organizationId,String organizationName,
|
||||||
MaterialCodeGenerator codeGenerator) {
|
MaterialCodeGenerator codeGenerator) {
|
||||||
Material material = new Material(ownerId, shipper, category, name, model,
|
Material material = new Material(ownerId, shipper, category, name, model,
|
||||||
unit, value, codeManaged, weight, materialVolume, materialContent, remark,
|
unit, value, codeManaged, weight, materialVolume, materialContent, remark,
|
||||||
topOrganizationId,organizationId
|
topOrganizationId,organizationId,organizationName
|
||||||
);
|
);
|
||||||
material.materialCode = codeGenerator.generate();
|
material.materialCode = codeGenerator.generate();
|
||||||
return material;
|
return material;
|
||||||
@@ -104,7 +107,7 @@ public class Material {
|
|||||||
BigDecimal weight,
|
BigDecimal weight,
|
||||||
BigDecimal materialVolume,
|
BigDecimal materialVolume,
|
||||||
String materialContent,
|
String materialContent,
|
||||||
String remark,String topOrganizationId,String organizationId ) {
|
String remark,String topOrganizationId,String organizationId,String organizationName ) {
|
||||||
this.ownerId = ownerId;
|
this.ownerId = ownerId;
|
||||||
this.shipper = shipper;
|
this.shipper = shipper;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
@@ -120,6 +123,7 @@ public class Material {
|
|||||||
this.updateTime = LocalDateTime.now();
|
this.updateTime = LocalDateTime.now();
|
||||||
this.topOrganizationId = topOrganizationId;
|
this.topOrganizationId = topOrganizationId;
|
||||||
this.organizationId = organizationId;
|
this.organizationId = organizationId;
|
||||||
|
this.organizationName = organizationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保留的核心校验
|
// 保留的核心校验
|
||||||
|
|||||||
+5
-1
@@ -57,15 +57,19 @@ public interface MaterialRepository {
|
|||||||
* @return 分页的物料数据
|
* @return 分页的物料数据
|
||||||
*/
|
*/
|
||||||
IPage<Material> search(String shipper, String category, String name,String model,String materialCode,Boolean codeManaged,String remark,String materialContent,
|
IPage<Material> search(String shipper, String category, String name,String model,String materialCode,Boolean codeManaged,String remark,String materialContent,
|
||||||
|
String organizationId, String organizationName, String topOrganizationId,
|
||||||
Long current, Long size);
|
Long current, Long size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有物料。
|
* 获取所有物料。
|
||||||
*
|
*
|
||||||
* @param ownerId 物料所属者ID
|
* @param ownerId 物料所属者ID
|
||||||
|
* @param organizationId 组织ID
|
||||||
|
* @param organizationName 组织名称
|
||||||
|
* @param topOrganizationId 一级组织ID
|
||||||
* @return 物料对象列表
|
* @return 物料对象列表
|
||||||
*/
|
*/
|
||||||
List<Material> findAllMaterials(Long ownerId);
|
List<Material> findAllMaterials(Long ownerId, String organizationId, String organizationName, String topOrganizationId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据所属者ID更新所属者名称。
|
* 根据所属者ID更新所属者名称。
|
||||||
|
|||||||
+3
-1
@@ -44,5 +44,7 @@ public interface InventoryMapper extends BaseMapper<Inventory> {
|
|||||||
*/
|
*/
|
||||||
Page<InventoryVO> findInventoryList(@Param("page") Page<InventoryVO> page, @Param("query") InventoryDTO.Query query);
|
Page<InventoryVO> findInventoryList(@Param("page") Page<InventoryVO> page, @Param("query") InventoryDTO.Query query);
|
||||||
|
|
||||||
List<InventoryVO> findAllInventoryList(@Param("ownerId") Long ownerId,@Param("machineSerialNo")String machineSerialNo);
|
List<InventoryVO> findAllInventoryList(@Param("ownerId") Long ownerId,
|
||||||
|
@Param("machineSerialNo") String machineSerialNo,
|
||||||
|
@Param("organizationId") String organizationId);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -40,4 +40,6 @@ public class MaterialDO {
|
|||||||
private String topOrganizationId;
|
private String topOrganizationId;
|
||||||
/**组织相关*/
|
/**组织相关*/
|
||||||
private String organizationId;
|
private String organizationId;
|
||||||
|
/**组织相关*/
|
||||||
|
private String organizationName;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-2
@@ -59,6 +59,7 @@ public class MaterialRepositoryImpl implements MaterialRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Material> search(String shipper, String category, String name, String model,String materialCode,Boolean codeManaged,String remark,String materialContent,
|
public IPage<Material> search(String shipper, String category, String name, String model,String materialCode,Boolean codeManaged,String remark,String materialContent,
|
||||||
|
String organizationId, String organizationName, String topOrganizationId,
|
||||||
Long current, Long size) {
|
Long current, Long size) {
|
||||||
LambdaQueryWrapper<MaterialDO> wrapper = Wrappers.<MaterialDO>lambdaQuery()
|
LambdaQueryWrapper<MaterialDO> wrapper = Wrappers.<MaterialDO>lambdaQuery()
|
||||||
.eq(StringUtils.isNotBlank(shipper), MaterialDO :: getShipper, shipper)
|
.eq(StringUtils.isNotBlank(shipper), MaterialDO :: getShipper, shipper)
|
||||||
@@ -69,6 +70,12 @@ public class MaterialRepositoryImpl implements MaterialRepository {
|
|||||||
.eq(null!=codeManaged, MaterialDO :: getCodeManaged, codeManaged)
|
.eq(null!=codeManaged, MaterialDO :: getCodeManaged, codeManaged)
|
||||||
.like(StringUtils.isNotBlank(remark), MaterialDO :: getRemark, remark)
|
.like(StringUtils.isNotBlank(remark), MaterialDO :: getRemark, remark)
|
||||||
.like(StringUtils.isNotBlank(materialContent), MaterialDO :: getMaterialContent, materialContent)
|
.like(StringUtils.isNotBlank(materialContent), MaterialDO :: getMaterialContent, materialContent)
|
||||||
|
.eq(StringUtils.isNotBlank(organizationId), MaterialDO :: getOrganizationId, organizationId)
|
||||||
|
.like(StringUtils.isNotBlank(organizationName), MaterialDO :: getOrganizationName, organizationName)
|
||||||
|
.eq(StringUtils.isNotBlank(topOrganizationId), MaterialDO :: getTopOrganizationId, topOrganizationId)
|
||||||
|
// 当设置了 organizationId 或 topOrganizationId 时,排除 organizationName 为 null 的数据
|
||||||
|
.and(StringUtils.isNotBlank(organizationId) || StringUtils.isNotBlank(topOrganizationId),
|
||||||
|
w -> w.isNotNull(MaterialDO::getOrganizationName))
|
||||||
.orderByDesc(MaterialDO :: getCreateTime);
|
.orderByDesc(MaterialDO :: getCreateTime);
|
||||||
|
|
||||||
return materialMapper.selectPage(new Page<>(current, size), wrapper)
|
return materialMapper.selectPage(new Page<>(current, size), wrapper)
|
||||||
@@ -86,9 +93,18 @@ public class MaterialRepositoryImpl implements MaterialRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Material> findAllMaterials(Long ownerId) {
|
public List<Material> findAllMaterials(Long ownerId, String organizationId, String organizationName, String topOrganizationId) {
|
||||||
|
LambdaQueryWrapper<MaterialDO> wrapper = Wrappers.<MaterialDO>lambdaQuery()
|
||||||
|
.eq(Objects.nonNull(ownerId), MaterialDO :: getOwnerId, ownerId)
|
||||||
|
.eq(StringUtils.isNotBlank(organizationId), MaterialDO :: getOrganizationId, organizationId)
|
||||||
|
.like(StringUtils.isNotBlank(organizationName), MaterialDO :: getOrganizationName, organizationName)
|
||||||
|
.eq(StringUtils.isNotBlank(topOrganizationId), MaterialDO :: getTopOrganizationId, topOrganizationId)
|
||||||
|
// 当设置了 organizationId 或 topOrganizationId 时,排除 organizationName 为 null 的数据
|
||||||
|
.and(StringUtils.isNotBlank(organizationId) || StringUtils.isNotBlank(topOrganizationId),
|
||||||
|
w -> w.isNotNull(MaterialDO::getOrganizationName));
|
||||||
|
|
||||||
return materialMapper
|
return materialMapper
|
||||||
.selectList(Wrappers.<MaterialDO>lambdaQuery().eq(Objects.nonNull(ownerId),MaterialDO :: getOwnerId, ownerId))
|
.selectList(wrapper)
|
||||||
.stream()
|
.stream()
|
||||||
.map(MaterialConverter :: convert)
|
.map(MaterialConverter :: convert)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user