Merge remote-tracking branch 'origin/dev_WMS20260401' into dev_WMS20260401

This commit is contained in:
zhou-hongcheng
2026-04-22 15:45:52 +08:00
6 changed files with 38 additions and 42 deletions
@@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -73,36 +72,6 @@ public class AssociationWarehouseApplicationService {
}
}
/**
* 排除「默认仓」关联(is_default=2),与 Mapper 条件双保险,避免 OGNL/参数未绑定导致仍查出默认行。
*/
private List<AssociationWarehousePO> filterExcludeDefaultWarehouse(
AssociationWarehouseDO associationWarehouseDO,
List<AssociationWarehousePO> list) {
if (!Boolean.TRUE.equals(associationWarehouseDO.getExcludeDefaultWarehouse())
|| list == null || list.isEmpty()) {
return list;
}
return list.stream()
.filter(po -> po.getIsDefault() == null || !Objects.equals(po.getIsDefault(), 2))
.collect(Collectors.toList());
}
/**
* 按「组织 + 仓库」查该仓下全部绑定(未带 correlationId)时,默认排除新建仓自动产生的默认仓关联(is_default=2)。
* 需要保留时显式传 excludeDefaultWarehouse=false。
* 仅在没有显式指定 excludeDefaultWarehouse 时生效。
*/
private void applyDefaultExcludeForWarehouseBindList(AssociationWarehouseDO associationWarehouseDO) {
if (associationWarehouseDO.getExcludeDefaultWarehouse() != null) {
return;
}
if (associationWarehouseDO.getWarehouseId() != null
&& associationWarehouseDO.getCorrelationId() == null) {
associationWarehouseDO.setExcludeDefaultWarehouse(true);
}
}
/**
* 分页查询关联仓库列表
*/
@@ -128,16 +97,14 @@ public class AssociationWarehouseApplicationService {
associationWarehousePO.setTopOrganizationId(warehousePO.getTopOrganizationId());
associationWarehousePOList.add(associationWarehousePO);
});
return filterExcludeDefaultWarehouse(associationWarehouseDO, associationWarehousePOList);
return associationWarehousePOList;
}else {
applyAssociationWarehouseOrgScope(associationWarehouseDO, loginUser);
// 未指定仓库时:只查当前登录人在关联表中的记录;指定了 warehouseId 时:查该仓下全部绑定(绑定用户列表),勿收窄为当前用户
if (associationWarehouseDO.getWarehouseId() == null) {
associationWarehouseDO.setCorrelationId(loginUser.getUserid());
}
applyDefaultExcludeForWarehouseBindList(associationWarehouseDO);
return filterExcludeDefaultWarehouse(associationWarehouseDO,
associationWarehouseDomainService.queryList(associationWarehouseDO));
return associationWarehouseDomainService.queryList(associationWarehouseDO);
}
}
@@ -146,9 +113,7 @@ public class AssociationWarehouseApplicationService {
if (loginUser != null && loginUser.getUserPo() != null) {
applyAssociationWarehouseOrgScope(associationWarehouseDO, loginUser);
}
applyDefaultExcludeForWarehouseBindList(associationWarehouseDO);
List<AssociationWarehousePO> associationWarehousePOList = filterExcludeDefaultWarehouse(associationWarehouseDO,
associationWarehouseDomainService.queryList(associationWarehouseDO));
List<AssociationWarehousePO> associationWarehousePOList = associationWarehouseDomainService.queryList(associationWarehouseDO);
return associationWarehousePOList.stream()
.map(AssociationWarehousePO::getCorrelationId)
.collect(Collectors.toList());
@@ -133,17 +133,30 @@ public class AssociationWarehouseImpl extends ServiceImpl<AssociationWarehouseMa
}
/**
* 批量删除关联仓库
* 批量删除关联仓库。is_default=2(新建仓自动产生的默认仓绑定)不可删,调用方传入的 id 会被过滤。
*/
@Override
public Boolean delete(Long[] associationWarehouseIds ) {
List<AssociationWarehouse> list = new ArrayList<>();
for (Long id : associationWarehouseIds) {
if (id == null) {
continue;
}
AssociationWarehouse row = this.getById(id);
if (row == null) {
continue;
}
if (row.getIsDefault() != null && row.getIsDefault() == 2) {
continue;
}
AssociationWarehouse associationWarehouse = new AssociationWarehouse();
associationWarehouse.setAssociationWarehouseId(id);
associationWarehouse.setDelFlag(2);
list.add(associationWarehouse);
}
if (list.isEmpty()) {
return Boolean.TRUE;
}
return this.updateBatchById(list);
}
@@ -40,9 +40,9 @@ public class AssociationWarehouseApi extends BaseController{
private AssociationWarehouseAssembler associationWarehouseAssembler;
/**
* 分页查询关联仓库列表。按组织+仓库(warehouseId)查该仓全部绑定时,默认不返回 is_default=2默认仓关联行;需要含该条时传 excludeDefaultWarehouse=false
* 分页查询关联仓库列表;含 is_default=2默认仓关联。删除时此类记录不可删
*/
@ApiOperation("查询关联仓库列表(按仓查绑定时默认不含 is_default=2")
@ApiOperation("查询关联仓库列表")
@GetMapping("/list")
public AjaxResult list(AssociationWarehouseDTO associationWarehouseDTO)
{
@@ -52,7 +52,7 @@ public class AssociationWarehouseApi extends BaseController{
return AjaxResult.success(list);
}
@ApiOperation("查询仓库关联的用户 id 集合(按仓查时默认不含仅 is_default=2 的绑定)")
@ApiOperation("查询仓库关联的用户 id 集合")
@GetMapping("/queryListCorrelationId")
public AjaxResult listUser(AssociationWarehouseDTO associationWarehouseDTO)
{
@@ -49,9 +49,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseId != null ">
and a.warehouse_id = #{warehouseId}
</if>
<!-- 查询含 is_default=2 的默认仓关联行;is_default=2 仅在删除/保存绑定时在 Service 中过滤,不再在 SQL 中排除 -->
<!--
<if test="excludeDefaultWarehouse != null and excludeDefaultWarehouse">
and (a.is_default is null or a.is_default &lt;&gt; 2)
</if>
-->
<if test="warehouseCode != null and warehouseCode != ''">
and a.warehouse_code = #{warehouseCode}
</if>
@@ -15,6 +15,15 @@ public class CopyCodeReferenceDTO extends BaseVOEntity {
@ApiModelProperty("ID")
private Long id;
@ApiModelProperty("组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("货主ID")
private Long shipperId;
@@ -125,6 +125,12 @@
AND material_code = #{materialCode}
AND batch_number = #{batchNumber}
AND box_pallet_no = #{boxPalletNo}
<if test="topOrganizationId != null">
AND top_organization_id = #{topOrganizationId}
</if>
<if test="organizationId != null">
AND organization_id = #{organizationId}
</if>
ORDER BY serial_number
</select>