Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
+63
-45
@@ -43,7 +43,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 租赁管理ApplicationService
|
||||
*
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-05-07
|
||||
*/
|
||||
@@ -67,8 +67,9 @@ public class LeaseApplicationService {
|
||||
private StorageSectionApplicationService storageSectionApplicationService;
|
||||
|
||||
@Autowired
|
||||
private IShipperLeaseDetailsService shipperLeaseDetailsService;
|
||||
|
||||
private IShipperLeaseDetailsService shipperLeaseDetailsService;
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
|
||||
/**
|
||||
* 分页查询租赁管理列表
|
||||
@@ -76,36 +77,57 @@ public class LeaseApplicationService {
|
||||
|
||||
public List<LeasePO> queryList(LeaseDO leaseDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null){
|
||||
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = leaseDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据organizationId来设置查询权限
|
||||
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
|
||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (leaseDO.getOrganizationId() == null) {
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
leaseDO.setOrganizationId(frontendOrganizationId);
|
||||
leaseDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
leaseDO.setOrganizationId(null);
|
||||
leaseDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
leaseDO.setTopOrganizationId(topOrganizationId);
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
leaseDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
leaseDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 如果前端传递了organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (leaseDO.getOrganizationId() != null && !leaseDO.getOrganizationId().equals(loginUserOrganizationId)) {
|
||||
// 前端传递了其他组织的organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
leaseDO.setOrganizationId(loginUserOrganizationId);
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (leaseDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
leaseDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
leaseDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return leaseDomainService.queryList(leaseDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增租赁管理
|
||||
*/
|
||||
@@ -125,12 +147,9 @@ public class LeaseApplicationService {
|
||||
return leaseDomainService.insert(leaseDO);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
|
||||
private void setWarehouseInfo(LeaseDO leaseDO) {
|
||||
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(leaseDO.getWarehouseId());
|
||||
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
throw new ServiceException("获取仓库信息失败");
|
||||
}
|
||||
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
|
||||
@@ -170,19 +189,18 @@ public class LeaseApplicationService {
|
||||
/**
|
||||
* 获取租赁管理详细信息
|
||||
*/
|
||||
public LeasePO getInfo(Long leaseId)
|
||||
{
|
||||
public LeasePO getInfo(Long leaseId) {
|
||||
return leaseDomainService.getInfo(leaseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param leaseIds
|
||||
* @return Boolean
|
||||
* @description 批量作废租赁
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/13 9:46
|
||||
* @param leaseIds
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean nullifyByIds(List<Long> leaseIds){
|
||||
public Boolean nullifyByIds(List<Long> leaseIds) {
|
||||
return leaseDomainService.nullifyByIds(leaseIds);
|
||||
}
|
||||
|
||||
@@ -196,8 +214,8 @@ public class LeaseApplicationService {
|
||||
log.info("开始执行货主租赁明细定时任务");
|
||||
// 计算前一天的日期,将时间设置为当天的0点0分0秒,只保留日期部分
|
||||
final Date yesterday = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1));
|
||||
|
||||
LeaseDO leaseDO = new LeaseDO();
|
||||
|
||||
LeaseDO leaseDO = new LeaseDO();
|
||||
leaseDO.setTime(yesterday);
|
||||
//查询有效期内的租赁
|
||||
List<LeasePO> leasePOS = queryList(leaseDO);
|
||||
@@ -207,10 +225,10 @@ public class LeaseApplicationService {
|
||||
List<LeasePO> casualRental = leasePOS.stream()
|
||||
.filter(lease -> lease.getLeaseType().equals("散租"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
List<ShipperLeaseDetails> shipperLeaseDetailsList = new ArrayList<>(); //需要保存或更新的数据
|
||||
List<ShipperLeaseDetails> shipperLeaseDetailsToUpdate = new ArrayList<>(); //需要更新的数据
|
||||
|
||||
|
||||
// 查询已存在的货主租赁明细数据(用于判断是新增还是更新)
|
||||
ShipperLeaseDetailsDO queryDO = new ShipperLeaseDetailsDO();
|
||||
queryDO.setBusinessDate(yesterday);
|
||||
@@ -218,18 +236,18 @@ public class LeaseApplicationService {
|
||||
// 构建已存在数据的Map,key为:业务日期+货主ID+仓库ID+租赁类型
|
||||
Map<String, ShipperLeaseDetailsPO> existingMap = existingList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
item -> buildKey(yesterday, item.getShipperId(), item.getWarehouseId(), item.getLeaseType()),
|
||||
item -> item,
|
||||
(existing, replacement) -> existing // 如果有重复key,保留第一个
|
||||
item -> buildKey(yesterday, item.getShipperId(), item.getWarehouseId(), item.getLeaseType()),
|
||||
item -> item,
|
||||
(existing, replacement) -> existing // 如果有重复key,保留第一个
|
||||
));
|
||||
|
||||
|
||||
// 处理整租
|
||||
for (LeasePO en : entireUnit) {
|
||||
String key = buildKey(yesterday, en.getShipperId(), en.getWarehouseId(), en.getLeaseType());
|
||||
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
|
||||
BeanUtils.copyProperties(en, shipperLeaseDetails);
|
||||
shipperLeaseDetails.setBusinessDate(yesterday);
|
||||
|
||||
|
||||
// 如果已存在,则更新;否则新增
|
||||
if (existingMap.containsKey(key)) {
|
||||
ShipperLeaseDetailsPO existing = existingMap.get(key);
|
||||
@@ -239,7 +257,7 @@ public class LeaseApplicationService {
|
||||
shipperLeaseDetailsList.add(shipperLeaseDetails);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理散租:从租赁管理页面维护的面积,效期内的散租客户面积之和
|
||||
for (LeasePO ca : casualRental) {
|
||||
String key = buildKey(yesterday, ca.getShipperId(), ca.getWarehouseId(), ca.getLeaseType());
|
||||
@@ -249,7 +267,7 @@ public class LeaseApplicationService {
|
||||
// 散租面积直接使用租赁管理页面维护的面积
|
||||
shipperLeaseDetails.setLeaseArea(ca.getLeaseArea());
|
||||
log.info("货主:{},仓库:{},散租面积:{}(来自租赁管理)", ca.getCargoOwnerName(), ca.getWarehouseName(), ca.getLeaseArea());
|
||||
|
||||
|
||||
// 如果已存在,则更新;否则新增
|
||||
if (existingMap.containsKey(key)) {
|
||||
ShipperLeaseDetailsPO existing = existingMap.get(key);
|
||||
@@ -259,22 +277,22 @@ public class LeaseApplicationService {
|
||||
shipperLeaseDetailsList.add(shipperLeaseDetails);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 批量新增货主租赁明细
|
||||
if (shipperLeaseDetailsList.size() > 0) {
|
||||
shipperLeaseDetailsService.saveBatch(shipperLeaseDetailsList);
|
||||
log.info("新增货主租赁明细{}条", shipperLeaseDetailsList.size());
|
||||
}
|
||||
|
||||
|
||||
// 批量更新货主租赁明细
|
||||
if (shipperLeaseDetailsToUpdate.size() > 0) {
|
||||
shipperLeaseDetailsService.updateBatchById(shipperLeaseDetailsToUpdate);
|
||||
log.info("更新货主租赁明细{}条", shipperLeaseDetailsToUpdate.size());
|
||||
}
|
||||
|
||||
|
||||
log.info("货主租赁明细定时任务执行完成,业务日期:{}", DateUtil.formatDate(yesterday));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建唯一key:业务日期+货主ID+仓库ID+租赁类型
|
||||
*/
|
||||
@@ -305,7 +323,7 @@ public class LeaseApplicationService {
|
||||
);
|
||||
//获取总面积
|
||||
BigDecimal totalArea = BigDecimal.ZERO;
|
||||
StorageSectionDO storageSectionDO = new StorageSectionDO();
|
||||
StorageSectionDO storageSectionDO = new StorageSectionDO();
|
||||
storageSectionDO.setWarehouseId(shipperLeaseDetailsDO.getWarehouseId());
|
||||
storageSectionDO.setOpeningUp(1);
|
||||
List<StorageSectionPO> storageSectionPOS = storageSectionApplicationService.queryList(storageSectionDO);
|
||||
@@ -323,9 +341,9 @@ public class LeaseApplicationService {
|
||||
BigDecimal fractionalLeaseArea = BigDecimal.ZERO;
|
||||
//计算整租和散租
|
||||
for (ShipperLeaseDetailsPO shipperLeaseDetail : shipperLeaseDetails) {
|
||||
if (shipperLeaseDetail.getLeaseType().equals("整租")){
|
||||
if (shipperLeaseDetail.getLeaseType().equals("整租")) {
|
||||
entireLeaseArea = entireLeaseArea.add(shipperLeaseDetail.getLeaseArea());
|
||||
}else {
|
||||
} else {
|
||||
fractionalLeaseArea = fractionalLeaseArea.add(shipperLeaseDetail.getLeaseArea());
|
||||
}
|
||||
warehouseOccupancyRate.setWarehouseName(shipperLeaseDetail.getWarehouseName());
|
||||
|
||||
+46
-4
@@ -39,10 +39,52 @@ public class BatchApplicationService {
|
||||
|
||||
public List<BatchPO> queryList(BatchDO batchDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
batchDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = batchDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
batchDO.setOrganizationId(frontendOrganizationId);
|
||||
batchDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
batchDO.setOrganizationId(null);
|
||||
batchDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
batchDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
batchDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (batchDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
batchDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
batchDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<BatchPO> batchPOS = batchDomainService.queryList(batchDO);
|
||||
|
||||
+46
-4
@@ -37,10 +37,52 @@ public class BrandApplicationService {
|
||||
|
||||
public List<BrandPO> queryList(BrandDO brandDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
brandDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = brandDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
brandDO.setOrganizationId(frontendOrganizationId);
|
||||
brandDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
brandDO.setOrganizationId(null);
|
||||
brandDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
brandDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
brandDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (brandDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
brandDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
brandDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return brandDomainService.queryList(brandDO);
|
||||
|
||||
+46
-4
@@ -43,10 +43,52 @@ public class MaterialBaseInfoApplicationService {
|
||||
|
||||
public List<MaterialBaseInfoPO> queryList(MaterialBaseInfoDO materialBaseInfoDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
materialBaseInfoDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = materialBaseInfoDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
materialBaseInfoDO.setOrganizationId(frontendOrganizationId);
|
||||
materialBaseInfoDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
materialBaseInfoDO.setOrganizationId(null);
|
||||
materialBaseInfoDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
materialBaseInfoDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
materialBaseInfoDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (materialBaseInfoDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
materialBaseInfoDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
materialBaseInfoDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return materialBaseInfoDomainService.queryList(materialBaseInfoDO);
|
||||
|
||||
+46
-4
@@ -29,10 +29,52 @@ public class MaterialClassifyApplicationService {
|
||||
|
||||
public List<MaterialClassifyPO> queryList(MaterialClassifyDO materialClassifyDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
materialClassifyDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = materialClassifyDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
materialClassifyDO.setOrganizationId(frontendOrganizationId);
|
||||
materialClassifyDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
materialClassifyDO.setOrganizationId(null);
|
||||
materialClassifyDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
materialClassifyDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
materialClassifyDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (materialClassifyDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
materialClassifyDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
materialClassifyDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return materialClassifyDomainService.queryList(materialClassifyDO);
|
||||
|
||||
+46
-4
@@ -38,10 +38,52 @@ public class PackApplicationService {
|
||||
|
||||
public List<PackPO> queryList(PackDO packDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
packDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = packDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
packDO.setOrganizationId(frontendOrganizationId);
|
||||
packDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
packDO.setOrganizationId(null);
|
||||
packDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
packDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
packDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (packDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
packDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
packDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return packDomainService.queryList(packDO);
|
||||
|
||||
+48
-5
@@ -44,13 +44,56 @@ public class StorageLocationApplicationService {
|
||||
|
||||
public List<StorageLocationPO> queryList(StorageLocationDO storageLocationDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
storageLocationDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = storageLocationDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
storageLocationDO.setOrganizationId(frontendOrganizationId);
|
||||
storageLocationDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
storageLocationDO.setOrganizationId(null);
|
||||
storageLocationDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
storageLocationDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
storageLocationDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (storageLocationDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
storageLocationDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
storageLocationDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
|
||||
// 只有当前端没有明确传仓库条件时,才使用用户关联仓库缓存进行过滤;
|
||||
// 避免出现“单据仓库=常温仓,但库位列表仍显示保税仓”的错配问题。
|
||||
// 避免出现"单据仓库=常温仓,但库位列表仍显示保税仓"的错配问题。
|
||||
boolean hasWarehouseFilter = storageLocationDO.getWarehouseId() != null
|
||||
|| (storageLocationDO.getWarehouseCode() != null && !storageLocationDO.getWarehouseCode().trim().isEmpty())
|
||||
|| (storageLocationDO.getWarehouseName() != null && !storageLocationDO.getWarehouseName().trim().isEmpty());
|
||||
|
||||
+46
-8
@@ -28,14 +28,52 @@ public class StorageLocationGroupApplicationService {
|
||||
|
||||
public List<StorageLocationGroupPO> queryList(StorageLocationGroupDO storageLocationGroupDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
storageLocationGroupDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
if (organizationId != null && organizationId != 1){
|
||||
storageLocationGroupDO.setOrganizationId(organizationId);
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = storageLocationGroupDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
storageLocationGroupDO.setOrganizationId(frontendOrganizationId);
|
||||
storageLocationGroupDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
storageLocationGroupDO.setOrganizationId(null);
|
||||
storageLocationGroupDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
storageLocationGroupDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
storageLocationGroupDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (storageLocationGroupDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
storageLocationGroupDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
storageLocationGroupDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return storageLocationGroupDomainService.queryList(storageLocationGroupDO);
|
||||
|
||||
+46
-4
@@ -43,10 +43,52 @@ public class StorageSectionApplicationService {
|
||||
|
||||
public List<StorageSectionPO> queryList(StorageSectionDO storageSectionDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
storageSectionDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = storageSectionDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
storageSectionDO.setOrganizationId(frontendOrganizationId);
|
||||
storageSectionDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
storageSectionDO.setOrganizationId(null);
|
||||
storageSectionDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
storageSectionDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
storageSectionDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (storageSectionDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
storageSectionDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
storageSectionDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return storageSectionDomainService.queryList(storageSectionDO);
|
||||
|
||||
+46
-4
@@ -42,10 +42,52 @@ public class WarehouseApplicationService {
|
||||
|
||||
public List<WarehousePO> queryList(WarehouseDO warehouseDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
if (organizationId != null && organizationId != 1){
|
||||
warehouseDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = warehouseDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
warehouseDO.setOrganizationId(frontendOrganizationId);
|
||||
warehouseDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
warehouseDO.setOrganizationId(null);
|
||||
warehouseDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
warehouseDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
warehouseDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (warehouseDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
warehouseDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
warehouseDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return warehouseDomainService.queryList(warehouseDO);
|
||||
|
||||
+13
-2
@@ -32,10 +32,21 @@ public class DifferentManageApplicationService {
|
||||
|
||||
public List<DifferentManagePO> queryList(DifferentManageDO differentManageDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// 当前登录用户组织ID为2827时,查询所有组织的数据
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 不设置organizationId,查询所有组织的数据
|
||||
differentManageDO.setOrganizationId(null);
|
||||
} else {
|
||||
// 其他情况,只查询当前登录用户所属组织的数据
|
||||
if (userOrganizationId != null) {
|
||||
differentManageDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
differentManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
differentManageDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
differentManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
|
||||
+49
-5
@@ -63,13 +63,57 @@ public class HandoverTaskOrderApplicationService {
|
||||
|
||||
public List<HandoverTaskOrderPO> queryList(HandoverTaskOrderDO handoverTaskOrderDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
handoverTaskOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = handoverTaskOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
handoverTaskOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
handoverTaskOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
handoverTaskOrderDO.setOrganizationId(null);
|
||||
handoverTaskOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
handoverTaskOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
handoverTaskOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (handoverTaskOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
handoverTaskOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
handoverTaskOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
handoverTaskOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
if (associationWarehouseCacheDO != null) {
|
||||
handoverTaskOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
}
|
||||
}
|
||||
return handoverTaskOrderDomainService.queryList(handoverTaskOrderDO);
|
||||
}
|
||||
|
||||
+13
-2
@@ -64,10 +64,21 @@ public class InvestigationManageApplicationService {
|
||||
|
||||
public List<InvestigationManagePO> queryList(InvestigationManageDO investigationManageDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// 当前登录用户组织ID为2827时,查询所有组织的数据
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 不设置organizationId,查询所有组织的数据
|
||||
investigationManageDO.setOrganizationId(null);
|
||||
} else {
|
||||
// 其他情况,只查询当前登录用户所属组织的数据
|
||||
if (userOrganizationId != null) {
|
||||
investigationManageDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
investigationManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
investigationManageDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
investigationManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
|
||||
+46
-4
@@ -59,10 +59,52 @@ public class MaterialBaseInfoApplicationService {
|
||||
|
||||
public List<MaterialBaseInfoPO> queryList(MaterialBaseInfoDO materialBaseInfoDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
materialBaseInfoDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = materialBaseInfoDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
materialBaseInfoDO.setOrganizationId(frontendOrganizationId);
|
||||
materialBaseInfoDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
materialBaseInfoDO.setOrganizationId(null);
|
||||
materialBaseInfoDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
materialBaseInfoDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
materialBaseInfoDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (materialBaseInfoDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
materialBaseInfoDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
materialBaseInfoDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<MaterialBaseInfoPO> materialBaseInfoPOS = materialBaseInfoDomainService.queryList(materialBaseInfoDO);
|
||||
|
||||
+15
-3
@@ -51,12 +51,24 @@ public class MaterialInventoryApplicationService {
|
||||
|
||||
public List<MaterialInventoryPO> queryList(MaterialInventoryDO materialInventoryDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
if (loginUser != null && loginUser.getUserPo() != null){
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// 当前登录用户组织ID为2827时,查询所有组织的数据
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 不设置organizationId,查询所有组织的数据
|
||||
materialInventoryDO.setOrganizationId(null);
|
||||
} else {
|
||||
// 其他情况,只查询当前登录用户所属组织的数据
|
||||
if (userOrganizationId != null) {
|
||||
materialInventoryDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 处理topOrganizationId逻辑
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
materialInventoryDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
materialInventoryDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
// 前端有传warehouseId则优先使用传参;未传时才使用“用户关联仓库”作为默认值
|
||||
// 前端有传warehouseId则优先使用传参;未传时才使用"用户关联仓库"作为默认值
|
||||
if (materialInventoryDO.getWarehouseId() == null) {
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO =
|
||||
SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
|
||||
+46
-6
@@ -61,13 +61,53 @@ public class PickingOrderApplicationService {
|
||||
|
||||
public List<PickingOrderPO> queryList(PickingOrderDO pickingOrderDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
pickingOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = pickingOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
pickingOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
pickingOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
pickingOrderDO.setOrganizationId(null);
|
||||
pickingOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
pickingOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
pickingOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (pickingOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
pickingOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
pickingOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
//AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
//pickingOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
}
|
||||
List<PickingOrderPO> pickingOrderPOList = pickingOrderDomainService.queryList(pickingOrderDO);
|
||||
|
||||
|
||||
+14
-3
@@ -67,10 +67,21 @@ public class ShiftManageApplicationService {
|
||||
|
||||
public List<ShiftManagePO> queryList(ShiftManageDO shiftManageDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// 当前登录用户组织ID为2827时,查询所有组织的数据
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 不设置organizationId,查询所有组织的数据
|
||||
shiftManageDO.setOrganizationId(null);
|
||||
} else {
|
||||
// 其他情况,只查询当前登录用户所属组织的数据
|
||||
if (userOrganizationId != null) {
|
||||
shiftManageDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
shiftManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
shiftManageDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
shiftManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
|
||||
+40
-6
@@ -119,7 +119,7 @@ public class ShiftMaterialDetailApplicationService {
|
||||
}
|
||||
|
||||
// 性能优化:批量获取批次属性,避免N+1查询问题
|
||||
// 1. 收集所有唯一的materialBaseInfoId
|
||||
// 1. 收集所有唯一的materialBaseInfoId(包括子项的,此时子项还未构建,所以直接遍历所有项)
|
||||
Set<Long> materialBaseInfoIdSet = list.stream()
|
||||
.map(ShiftMaterialDetailPO::getMaterialBaseInfoId)
|
||||
.filter(Objects::nonNull)
|
||||
@@ -146,18 +146,47 @@ public class ShiftMaterialDetailApplicationService {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 为每个物料明细设置更多属性(从库存表中获取值)
|
||||
setMaterialMoreDetailListFromInventory(list, batchDetailMap);
|
||||
// 3. 构建父子关系(类似queryListChildren的逻辑)
|
||||
List<ShiftMaterialDetailPO> parentList = list.stream()
|
||||
.filter(e -> e.getLevel() != null && e.getLevel() == 1)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return list;
|
||||
// 递归构建子项关系
|
||||
parentList.forEach(parent -> {
|
||||
List<ShiftMaterialDetailPO> children = getChildren(parent.getUniqueId(), list, 2);
|
||||
parent.setChildren(children);
|
||||
});
|
||||
|
||||
// 4. 为每个物料明细(包括子项)设置更多属性(从库存表中获取值)
|
||||
setMaterialMoreDetailListFromInventoryRecursively(parentList, batchDetailMap);
|
||||
|
||||
return parentList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为移位物料明细设置更多属性(从库存表中获取值)
|
||||
* 递归获取子项
|
||||
*/
|
||||
private List<ShiftMaterialDetailPO> getChildren(Long parentUniqueId, List<ShiftMaterialDetailPO> allList, Integer maxLevel) {
|
||||
List<ShiftMaterialDetailPO> childrenList = allList.stream()
|
||||
.filter(materialDetailPO -> parentUniqueId != null && parentUniqueId.equals(materialDetailPO.getParentUniqueId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(childrenList)) {
|
||||
childrenList.forEach(child -> {
|
||||
if (child.getLevel() != null && child.getLevel() < maxLevel) {
|
||||
child.setChildren(getChildren(child.getUniqueId(), allList, maxLevel));
|
||||
}
|
||||
});
|
||||
}
|
||||
return childrenList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为移位物料明细设置更多属性(从库存表中获取值),递归处理子项
|
||||
* @param shiftMaterialDetailPOList 移位物料明细列表
|
||||
* @param batchDetailMap 批次属性Map
|
||||
*/
|
||||
private void setMaterialMoreDetailListFromInventory(List<ShiftMaterialDetailPO> shiftMaterialDetailPOList,
|
||||
private void setMaterialMoreDetailListFromInventoryRecursively(List<ShiftMaterialDetailPO> shiftMaterialDetailPOList,
|
||||
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
|
||||
if (CollectionUtils.isEmpty(shiftMaterialDetailPOList)) {
|
||||
return;
|
||||
@@ -235,6 +264,11 @@ public class ShiftMaterialDetailApplicationService {
|
||||
shiftMaterialDetailPO.getUniqueId(), shiftMaterialDetailPO.getMaterialBaseInfoId(),
|
||||
shiftMaterialDetailPO.getMaterialInventoryId(),
|
||||
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
|
||||
|
||||
// 递归处理子项
|
||||
if (!CollectionUtils.isEmpty(shiftMaterialDetailPO.getChildren())) {
|
||||
setMaterialMoreDetailListFromInventoryRecursively(shiftMaterialDetailPO.getChildren(), batchDetailMap);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+46
-4
@@ -68,10 +68,52 @@ public class StockInOrderApplicationService {
|
||||
|
||||
public List<StockInOrderPO> queryList(StockInOrderDO stockInOrderDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
stockInOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null){
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = stockInOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
stockInOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
stockInOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
stockInOrderDO.setOrganizationId(null);
|
||||
stockInOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
stockInOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
stockInOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (stockInOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
stockInOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
stockInOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
// 前端有传warehouseId则优先使用传参;未传时才使用"用户关联仓库"作为默认值
|
||||
if (stockInOrderDO.getWarehouseId() == null) {
|
||||
|
||||
+115
-1
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mhd.common.core.constant.SnowFlakeConstants;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.enums.DictCode;
|
||||
@@ -23,14 +24,19 @@ import com.mhd.system.api.domain.WarehouseFeignPO;
|
||||
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
|
||||
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
|
||||
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
|
||||
import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService;
|
||||
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
|
||||
import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail;
|
||||
import com.mhd.wms.domain.outMaterialDetail.repository.facade.IOutMaterialDetailService;
|
||||
import com.mhd.wms.domain.outMaterialDetail.repository.po.OutMaterialCheckPO;
|
||||
import com.mhd.wms.domain.outMaterialDetail.repository.po.OutMaterialDetailPO;
|
||||
import com.mhd.wms.domain.outMaterialDetail.repository.todo.OutMaterialDetailDO;
|
||||
import com.mhd.wms.domain.outMaterialDetail.service.OutMaterialDetailDomainService;
|
||||
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.po.StockOutOrderPO;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO;
|
||||
import com.mhd.wms.domain.stockOutOrder.service.StockOutOrderDomainService;
|
||||
@@ -69,6 +75,10 @@ public class StockOutOrderApplicationService {
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Autowired
|
||||
private IdGenerator idGenerator;
|
||||
@Autowired
|
||||
private IStockOutOrderService stockOutOrderService;
|
||||
@Autowired
|
||||
private IOutMaterialDetailService outMaterialDetailService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -85,6 +95,54 @@ public class StockOutOrderApplicationService {
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
stockOutOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
}*/
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = stockOutOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
stockOutOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
stockOutOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
stockOutOrderDO.setOrganizationId(null);
|
||||
stockOutOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
stockOutOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
stockOutOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (stockOutOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
stockOutOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
stockOutOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stockOutOrderDomainService.queryList(stockOutOrderDO);
|
||||
}
|
||||
|
||||
@@ -522,10 +580,66 @@ public class StockOutOrderApplicationService {
|
||||
return stockOutOrderDomainService.manualAssign(assembleStockOutOrderDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 手动分配
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/28 13:47
|
||||
* @param stockOutOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean autoAssign(StockOutOrderDO stockOutOrderDO){
|
||||
List<Long> outOrderIds = stockOutOrderDO.getOutOrderIds();
|
||||
if (outOrderIds == null || outOrderIds.isEmpty()){
|
||||
throw new ServiceException("出库单ID不能为空");
|
||||
}
|
||||
Boolean result = true;
|
||||
for (Long outOrderId : outOrderIds){
|
||||
StockOutOrderDO stockOutOrderD = new StockOutOrderDO();
|
||||
StockOutOrder stockOutOrderDb = stockOutOrderService.getById(outOrderId);
|
||||
if (stockOutOrderDb == null){
|
||||
throw new ServiceException("出库单ID不存在");
|
||||
}
|
||||
BeanUtils.copyProperties(stockOutOrderDb, stockOutOrderD);
|
||||
List<OutMaterialDetail> outMaterialDetailList = outMaterialDetailService.list(new QueryWrapper<OutMaterialDetail>().lambda()
|
||||
.eq(OutMaterialDetail::getOutOrderNumber, stockOutOrderDb.getOutOrderNumber()));
|
||||
List<OutMaterialDetailDO> materialDetailList = cn.hutool.core.bean.BeanUtil.copyToList(outMaterialDetailList, OutMaterialDetailDO.class);
|
||||
for (OutMaterialDetailDO detail : materialDetailList) {
|
||||
detail.setAllocationQuantity(detail.getQuantity());
|
||||
String batchRefNo = detail.getBatchRefNo();
|
||||
String sheetRefNo = detail.getSheetRefNo();
|
||||
String boxPalletNo = detail.getBoxPalletNo();
|
||||
Long materialBaseInfoId = detail.getMaterialBaseInfoId();
|
||||
List<MaterialInventory> materialInventories = materialInventoryMapper.selectList(new QueryWrapper<MaterialInventory>().lambda()
|
||||
.eq(MaterialInventory::getBatchRefNo, batchRefNo)
|
||||
.eq(MaterialInventory::getSheetRefNo, sheetRefNo)
|
||||
.eq(MaterialInventory::getBoxPalletNo, boxPalletNo)
|
||||
.eq(MaterialInventory::getMaterialBaseInfoId, materialBaseInfoId));
|
||||
if (materialInventories == null || materialInventories.isEmpty()) {
|
||||
throw new ServiceException("库存不存在:" + batchRefNo + " " + sheetRefNo + " " + boxPalletNo);
|
||||
}
|
||||
MaterialInventory materialInventory = materialInventories.get(0);
|
||||
detail.setMaterialInventoryId(materialInventory.getMaterialInventoryId());
|
||||
detail.setStorageLocationId(materialInventory.getStorageLocationId());
|
||||
detail.setStorageLocationName(materialInventory.getStorageLocationName());
|
||||
detail.setStorageLocationCode(materialInventory.getStorageLocationCode());
|
||||
detail.setStorageSectionId(materialInventory.getStorageSectionId());
|
||||
detail.setStorageName(materialInventory.getStorageName());
|
||||
detail.setStorageCode(materialInventory.getStorageCode());
|
||||
}
|
||||
stockOutOrderD.setMaterialDetailList(materialDetailList);
|
||||
StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderDO);
|
||||
Boolean assignResult = stockOutOrderDomainService.autoAssign(assembleStockOutOrderDO);
|
||||
if (!assignResult) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*public Boolean autoAssign(StockOutOrderDO stockOutOrderDO){
|
||||
StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderDO);
|
||||
return stockOutOrderDomainService.autoAssign(assembleStockOutOrderDO);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @description 取消分配
|
||||
|
||||
+49
-5
@@ -46,13 +46,57 @@ public class StockOutTaskOrderApplicationService {
|
||||
|
||||
public List<StockOutTaskOrderPO> queryList(StockOutTaskOrderDO stockOutTaskOrderDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
stockOutTaskOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = stockOutTaskOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
stockOutTaskOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
stockOutTaskOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
stockOutTaskOrderDO.setOrganizationId(null);
|
||||
stockOutTaskOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
stockOutTaskOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
stockOutTaskOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (stockOutTaskOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
stockOutTaskOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
stockOutTaskOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
stockOutTaskOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
if (associationWarehouseCacheDO != null) {
|
||||
stockOutTaskOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
}
|
||||
}
|
||||
return stockOutTaskOrderDomainService.queryList(stockOutTaskOrderDO);
|
||||
}
|
||||
|
||||
+46
-4
@@ -91,10 +91,52 @@ public class StockReceiptOrderApplicationService {
|
||||
|
||||
public List<StockReceiptOrderPO> queryList(StockReceiptOrderDO stockReceiptOrderDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
stockReceiptOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null){
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = stockReceiptOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
stockReceiptOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
stockReceiptOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
stockReceiptOrderDO.setOrganizationId(null);
|
||||
stockReceiptOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
stockReceiptOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
stockReceiptOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (stockReceiptOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
stockReceiptOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
stockReceiptOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
try {
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
|
||||
+46
-4
@@ -97,10 +97,52 @@ public class StockShelfOrderApplicationService {
|
||||
|
||||
public List<StockShelfOrderPO> queryList(StockShelfOrderDO stockShelfOrderDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
stockShelfOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
if (loginUser != null && loginUser.getUserPo() != null){
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = stockShelfOrderDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
stockShelfOrderDO.setOrganizationId(frontendOrganizationId);
|
||||
stockShelfOrderDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
stockShelfOrderDO.setOrganizationId(null);
|
||||
stockShelfOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
stockShelfOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
stockShelfOrderDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (stockShelfOrderDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
stockShelfOrderDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
stockShelfOrderDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
try {
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
|
||||
+4
@@ -147,6 +147,10 @@ public class InMaterialDetailImpl extends ServiceImpl<InMaterialDetailMapper, In
|
||||
inMaterialDetail.setCreateBy(loginUser.getUserid());
|
||||
inMaterialDetail.setCreateByName(loginUser.getUsername());
|
||||
inMaterialDetail.setCreateTime(new Date());
|
||||
// 新增入库单明细时,如果计划数量为空,则使用入库数量作为计划数量
|
||||
if (inMaterialDetail.getQuantity() == null && inMaterialDetailDO.getInboundQuantity() != null) {
|
||||
inMaterialDetail.setQuantity(inMaterialDetailDO.getInboundQuantity());
|
||||
}
|
||||
inMaterialDetailList.add(inMaterialDetail);
|
||||
}
|
||||
return saveBatch(inMaterialDetailList);
|
||||
|
||||
+43
-10
@@ -75,26 +75,54 @@ public class MaterialBarCodeImpl extends ServiceImpl<MaterialBarCodeMapper, Mate
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
//标记之前的数据删除
|
||||
materialBarCodeMapper.update(null, new UpdateWrapper<MaterialBarCode>().lambda()
|
||||
.set(MaterialBarCode::getDelFlag, 2)
|
||||
.set(MaterialBarCode::getUpdateBy, loginUser.getUserid())
|
||||
.set(MaterialBarCode::getUpdateByName, loginUser.getUsername())
|
||||
.set(MaterialBarCode::getUpdateTime, new Date())
|
||||
.eq(MaterialBarCode::getMaterialBaseInfoId, materialBarCodeDOList.get(0).getMaterialBaseInfoId())
|
||||
.eq(MaterialBarCode::getDelFlag, 1));
|
||||
Long materialBaseInfoId = materialBarCodeDOList.get(0).getMaterialBaseInfoId();
|
||||
|
||||
// 先物理删除该物料的所有旧条码记录(包括已标记删除的),避免唯一性约束冲突
|
||||
// 因为唯一性约束 IDX_MATERIAL_BASE_ID_BAR_CODE 可能检查所有记录(包括 delFlag=2 的记录)
|
||||
// 使用 Mapper 的 delete 方法进行物理删除,绕过逻辑删除拦截器
|
||||
materialBarCodeMapper.delete(new QueryWrapper<MaterialBarCode>().lambda()
|
||||
.eq(MaterialBarCode::getMaterialBaseInfoId, materialBaseInfoId));
|
||||
|
||||
// 去重处理:确保没有重复的 material_base_info_id + bar_code 组合
|
||||
// 使用 LinkedHashMap 保持顺序,对所有记录进行去重
|
||||
// 对于 barCode 为 null 的记录,使用 packDetailId 来区分(因为唯一性约束可能不允许多个 null)
|
||||
java.util.Map<String, MaterialBarCode> uniqueMap = new java.util.LinkedHashMap<>();
|
||||
List<MaterialBarCode> materialBarCodeList = new ArrayList<>();
|
||||
|
||||
for (MaterialBarCodeDO materialBarCodeDO : materialBarCodeDOList){
|
||||
String barCode = materialBarCodeDO.getBarCode();
|
||||
String key;
|
||||
// 构建唯一性 key:material_base_info_id + bar_code
|
||||
// 如果 barCode 为 null 或空,使用 packDetailId 来区分,避免多条 null 值违反唯一性约束
|
||||
if (barCode != null && !barCode.trim().isEmpty()) {
|
||||
key = materialBaseInfoId + "_" + barCode.trim();
|
||||
} else {
|
||||
// barCode 为 null 或空时,使用 packDetailId 来区分
|
||||
// 如果 packDetailId 也为 null,则使用固定值(只保留第一条)
|
||||
Long packDetailId = materialBarCodeDO.getPackDetailId();
|
||||
key = materialBaseInfoId + "_null_" + (packDetailId != null ? packDetailId : "empty");
|
||||
}
|
||||
// 如果已存在相同的组合,跳过(保留第一个),避免违反唯一性约束
|
||||
if (uniqueMap.containsKey(key)) {
|
||||
continue;
|
||||
}
|
||||
// 创建新的条码记录
|
||||
MaterialBarCode materialBarCode = new MaterialBarCode();
|
||||
BeanUtils.copyProperties(materialBarCodeDO,materialBarCode);
|
||||
BeanUtils.copyProperties(materialBarCodeDO, materialBarCode);
|
||||
materialBarCode.setOrganizationId(userPo.getOrganizationId());
|
||||
materialBarCode.setOrganizationName(userPo.getOrganizationName());
|
||||
materialBarCode.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
materialBarCode.setCreateBy(loginUser.getUserid());
|
||||
materialBarCode.setCreateByName(loginUser.getUsername());
|
||||
materialBarCode.setCreateTime(new Date());
|
||||
materialBarCode.setDelFlag(1);
|
||||
// 添加到去重 Map 和列表
|
||||
uniqueMap.put(key, materialBarCode);
|
||||
materialBarCodeList.add(materialBarCode);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(materialBarCodeList)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.saveBatch(materialBarCodeList);
|
||||
}
|
||||
@@ -157,7 +185,12 @@ public class MaterialBarCodeImpl extends ServiceImpl<MaterialBarCodeMapper, Mate
|
||||
return null;
|
||||
}
|
||||
List<MaterialBarCodePO> materialBarCodePOList = new ArrayList<>();
|
||||
BeanUtils.copyProperties(materialBarCodeList,materialBarCodePOList);
|
||||
// 遍历列表,逐个复制每个对象的属性
|
||||
for (MaterialBarCode materialBarCode : materialBarCodeList) {
|
||||
MaterialBarCodePO materialBarCodePO = new MaterialBarCodePO();
|
||||
BeanUtils.copyProperties(materialBarCode, materialBarCodePO);
|
||||
materialBarCodePOList.add(materialBarCodePO);
|
||||
}
|
||||
return materialBarCodePOList;
|
||||
}
|
||||
}
|
||||
|
||||
+68
-1
@@ -41,6 +41,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -113,7 +114,9 @@ public class ShiftManageImpl extends ServiceImpl<ShiftManageMapper, ShiftManage>
|
||||
setWarehouseInfo(e);
|
||||
//设置物料信息
|
||||
setMaterialDetailInfo(e);
|
||||
e.setUniqueId(idGenerator.snowflakeId(SnowFlakeConstants.wmsId));
|
||||
// 设置父级信息
|
||||
Long parentUniqueId = idGenerator.snowflakeId(SnowFlakeConstants.wmsId);
|
||||
e.setUniqueId(parentUniqueId);
|
||||
e.setShiftNumber(shiftManage.getShiftNumber());
|
||||
e.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
e.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
@@ -125,10 +128,74 @@ public class ShiftManageImpl extends ServiceImpl<ShiftManageMapper, ShiftManage>
|
||||
e.setUpdateBy(loginUser.getUserid());
|
||||
e.setUpdateTime(new Date());
|
||||
e.setSerialNumberManage(e.getSerialNumberManage());
|
||||
// 设置父级level为1
|
||||
if (e.getLevel() == null) {
|
||||
e.setLevel(1);
|
||||
}
|
||||
ShiftMaterialDetail shiftMaterialDetail = new ShiftMaterialDetail();
|
||||
BeanUtils.copyProperties(e, shiftMaterialDetail);
|
||||
shiftMaterialDetail.setNewStorageLocationName(newStorageLocationName);
|
||||
shiftMaterialDetailList.add(shiftMaterialDetail);
|
||||
|
||||
// 处理子项
|
||||
List<ShiftMaterialDetailDO> shiftMaterialDetailDOChildList = e.getChildren();
|
||||
if (!CollectionUtils.isEmpty(shiftMaterialDetailDOChildList)) {
|
||||
for (ShiftMaterialDetailDO shiftMaterialDetailDOChild : shiftMaterialDetailDOChildList) {
|
||||
// 如果子项没有materialInventoryId,则从父级继承库存相关信息
|
||||
if (shiftMaterialDetailDOChild.getMaterialInventoryId() == null) {
|
||||
// 从父级继承库存相关信息
|
||||
shiftMaterialDetailDOChild.setMaterialInventoryId(e.getMaterialInventoryId());
|
||||
shiftMaterialDetailDOChild.setMaterialBaseInfoId(e.getMaterialBaseInfoId());
|
||||
shiftMaterialDetailDOChild.setMaterialCode(e.getMaterialCode());
|
||||
shiftMaterialDetailDOChild.setMaterialName(e.getMaterialName());
|
||||
shiftMaterialDetailDOChild.setBarCode(e.getBarCode());
|
||||
shiftMaterialDetailDOChild.setInventoryQuantity(e.getInventoryQuantity());
|
||||
shiftMaterialDetailDOChild.setOldWarehouseId(e.getOldWarehouseId());
|
||||
shiftMaterialDetailDOChild.setOldWarehouseCode(e.getOldWarehouseCode());
|
||||
shiftMaterialDetailDOChild.setOldWarehouseName(e.getOldWarehouseName());
|
||||
shiftMaterialDetailDOChild.setOldStorageSectionId(e.getOldStorageSectionId());
|
||||
shiftMaterialDetailDOChild.setOldStorageCode(e.getOldStorageCode());
|
||||
shiftMaterialDetailDOChild.setOldStorageName(e.getOldStorageName());
|
||||
shiftMaterialDetailDOChild.setOldStorageLocationId(e.getOldStorageLocationId());
|
||||
shiftMaterialDetailDOChild.setOldStorageLocationCode(e.getOldStorageLocationCode());
|
||||
shiftMaterialDetailDOChild.setOldStorageLocationName(e.getOldStorageLocationName());
|
||||
shiftMaterialDetailDOChild.setBatchNumber(e.getBatchNumber());
|
||||
shiftMaterialDetailDOChild.setMaterialStatusCode(e.getMaterialStatusCode());
|
||||
shiftMaterialDetailDOChild.setMaterialStatusName(e.getMaterialStatusName());
|
||||
shiftMaterialDetailDOChild.setContainerId(e.getContainerId());
|
||||
shiftMaterialDetailDOChild.setContainerCode(e.getContainerCode());
|
||||
shiftMaterialDetailDOChild.setContainerType(e.getContainerType());
|
||||
shiftMaterialDetailDOChild.setContainerTypeName(e.getContainerTypeName());
|
||||
} else {
|
||||
// 如果子项有materialInventoryId,则设置库存信息
|
||||
setMaterialInventory(shiftMaterialDetailDOChild);
|
||||
}
|
||||
// 设置库位信息和物料信息
|
||||
setWarehouseInfo(shiftMaterialDetailDOChild);
|
||||
setMaterialDetailInfo(shiftMaterialDetailDOChild);
|
||||
|
||||
// 设置子项的uniqueId和parentUniqueId
|
||||
Long childUniqueId = idGenerator.snowflakeId(SnowFlakeConstants.wmsId);
|
||||
shiftMaterialDetailDOChild.setUniqueId(childUniqueId);
|
||||
shiftMaterialDetailDOChild.setParentUniqueId(parentUniqueId);
|
||||
shiftMaterialDetailDOChild.setShiftNumber(shiftManage.getShiftNumber());
|
||||
shiftMaterialDetailDOChild.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
shiftMaterialDetailDOChild.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
shiftMaterialDetailDOChild.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
shiftMaterialDetailDOChild.setCreateByName(loginUser.getUsername());
|
||||
shiftMaterialDetailDOChild.setCreateBy(loginUser.getUserid());
|
||||
shiftMaterialDetailDOChild.setCreateTime(new Date());
|
||||
shiftMaterialDetailDOChild.setUpdateByName(loginUser.getUsername());
|
||||
shiftMaterialDetailDOChild.setUpdateBy(loginUser.getUserid());
|
||||
shiftMaterialDetailDOChild.setUpdateTime(new Date());
|
||||
// 设置子项level为2
|
||||
shiftMaterialDetailDOChild.setLevel(2);
|
||||
|
||||
ShiftMaterialDetail shiftMaterialDetailChild = new ShiftMaterialDetail();
|
||||
BeanUtils.copyProperties(shiftMaterialDetailDOChild, shiftMaterialDetailChild);
|
||||
shiftMaterialDetailList.add(shiftMaterialDetailChild);
|
||||
}
|
||||
}
|
||||
});
|
||||
iShiftMaterialDetailService.saveBatch(shiftMaterialDetailList);
|
||||
Boolean b;
|
||||
|
||||
+29
-1
@@ -249,7 +249,35 @@ public class StockOutOrderDomainService {
|
||||
return updateStockOutOrderByAllocation(stockOutOrderDb, stockOutOrderPO, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 手动分配
|
||||
* @author ZhouGY
|
||||
* @date 2024/5/22 16:20
|
||||
* @param stockOutOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean autoAssign(StockOutOrderDO stockOutOrderDO){
|
||||
List<Long> outOrderIds = stockOutOrderDO.getOutOrderIds();
|
||||
if (outOrderIds == null || outOrderIds.isEmpty()){
|
||||
throw new ServiceException("出库单ID不能为空");
|
||||
}
|
||||
StockOutOrder stockOutOrderDb = stockOutOrderService.getById(stockOutOrderDO.getOutOrderId());
|
||||
if (stockOutOrderDb == null){
|
||||
throw new ServiceException("出库单不存在");
|
||||
}
|
||||
if (stockOutOrderDb.getStatus() > 3){
|
||||
throw new ServiceException("收货单已完成分配");
|
||||
}
|
||||
List<OutMaterialDetail> outMaterialDetailList = outMaterialDetailService.list(new QueryWrapper<OutMaterialDetail>().lambda()
|
||||
.eq(OutMaterialDetail::getOutOrderNumber, stockOutOrderDb.getOutOrderNumber()));
|
||||
//修改物料明细信息
|
||||
StockOutOrderPO stockOutOrderPO = outMaterialDetailService.batchAssignUpdate(stockOutOrderDb.getOutOrderNumber(), stockOutOrderDO.getMaterialDetailList());
|
||||
//修改出库单
|
||||
return updateStockOutOrderByAllocation(stockOutOrderDb, stockOutOrderPO, 1);
|
||||
}
|
||||
|
||||
/*@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean autoAssign(StockOutOrderDO stockOutOrderDO){
|
||||
StockOutOrder stockOutOrderDb = stockOutOrderService.getById(stockOutOrderDO.getOutOrderId());
|
||||
if (stockOutOrderDb == null){
|
||||
@@ -273,7 +301,7 @@ public class StockOutOrderDomainService {
|
||||
StockOutOrderPO stockOutOrderPO = outMaterialDetailService.batchAssignUpdate(stockOutOrderDb.getOutOrderNumber(), stockOutOrderDO.getMaterialDetailList());
|
||||
//修改出库单
|
||||
return updateStockOutOrderByAllocation(stockOutOrderDb, stockOutOrderPO, 1);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @description 手动取消分配(点击确认后直接取消分配)
|
||||
|
||||
+13
-2
@@ -173,6 +173,17 @@ public class StockOutOrderApi extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手动分配
|
||||
*/
|
||||
@ApiOperation("自动分配")
|
||||
@PostMapping("/autoAssign")
|
||||
public AjaxResult autoAssign(@RequestBody StockOutOrderDTO stockOutOrderDTO) {
|
||||
StockOutOrderDO stockOutOrderDO = new StockOutOrderDO();
|
||||
BeanUtils.copyProperties(stockOutOrderDTO, stockOutOrderDO);
|
||||
return toAjax(stockOutOrderApplicationService.autoAssign(stockOutOrderDO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消分配
|
||||
*/
|
||||
@@ -325,12 +336,12 @@ public class StockOutOrderApi extends BaseController {
|
||||
/**
|
||||
* 自动分配
|
||||
*/
|
||||
@ApiOperation("自动分配")
|
||||
/*@ApiOperation("自动分配")
|
||||
@PostMapping("/autoAssign")
|
||||
public AjaxResult autoAssign(@RequestBody StockOutOrderDTO stockOutOrderDTO) {
|
||||
StockOutOrderDO stockOutOrderDO = JSONUtil.toBean(JSONUtil.toJsonStr(stockOutOrderDTO), StockOutOrderDO.class);
|
||||
return toAjax(stockOutOrderApplicationService.autoAssign(stockOutOrderDO));
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@ApiOperation("关闭出库单")
|
||||
|
||||
Reference in New Issue
Block a user