Merge remote-tracking branch 'gitee/0.8.X' into 0.8.X

This commit is contained in:
2026-01-28 18:41:13 +08:00
12 changed files with 632 additions and 329 deletions

View File

@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.klp.common.utils.StringUtils;
import com.klp.common.exception.ServiceException;
import com.klp.domain.WmsDeliveryWaybill;
import com.klp.mapper.WmsDeliveryWaybillMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.klp.domain.bo.WmsDeliveryWaybillDetailBo;
@@ -20,6 +22,7 @@ import com.klp.service.IWmsDeliveryWaybillDetailService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.stream.Collectors;
/**
* 发货单明细Service业务层处理
@@ -33,6 +36,8 @@ public class WmsDeliveryWaybillDetailServiceImpl implements IWmsDeliveryWaybillD
private final WmsDeliveryWaybillDetailMapper baseMapper;
private final WmsDeliveryWaybillMapper wmsDeliveryWaybillMapper;
/**
* 查询发货单明细
*/
@@ -98,6 +103,20 @@ public class WmsDeliveryWaybillDetailServiceImpl implements IWmsDeliveryWaybillD
*/
@Override
public Boolean updateByBo(WmsDeliveryWaybillDetailBo bo) {
// 检查关联的发货单主表状态,如果已发货则不允许修改
if (bo.getDetailId() != null) {
WmsDeliveryWaybillDetail existingDetail = baseMapper.selectById(bo.getDetailId());
if (existingDetail != null) {
// 查询关联的发货单状态
LambdaQueryWrapper<WmsDeliveryWaybill> waybillQueryWrapper = new LambdaQueryWrapper<>();
waybillQueryWrapper.eq(WmsDeliveryWaybill::getWaybillId, existingDetail.getWaybillId())
.eq(WmsDeliveryWaybill::getStatus, 1); // 已发货状态
if (wmsDeliveryWaybillMapper.exists(waybillQueryWrapper)) {
throw new RuntimeException("明细所属的发货单已发货,无法修改明细记录");
}
}
}
WmsDeliveryWaybillDetail update = BeanUtil.toBean(bo, WmsDeliveryWaybillDetail.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
@@ -141,7 +160,27 @@ public class WmsDeliveryWaybillDetailServiceImpl implements IWmsDeliveryWaybillD
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
// 检查明细是否关联到已发货的运单
if (ids != null && !ids.isEmpty()) {
// 获取明细记录以检查它们关联的运单ID
List<WmsDeliveryWaybillDetail> details = baseMapper.selectBatchIds(ids);
if (details != null && !details.isEmpty()) {
// 提取关联的运单ID
List<Long> waybillIds = details.stream()
.map(WmsDeliveryWaybillDetail::getWaybillId)
.distinct()
.collect(Collectors.toList());
// 检查这些运单是否已发货
LambdaQueryWrapper<WmsDeliveryWaybill> waybillQueryWrapper = new LambdaQueryWrapper<>();
waybillQueryWrapper.in(WmsDeliveryWaybill::getWaybillId, waybillIds)
.eq(WmsDeliveryWaybill::getStatus, 1);
if (wmsDeliveryWaybillMapper.exists(waybillQueryWrapper)) {
throw new RuntimeException("明细所属的发货单已发货,无法删除明细记录");
}
}
}
}
return baseMapper.deleteBatchIds(ids) > 0;
}

View File

@@ -136,6 +136,15 @@ public class WmsDeliveryWaybillServiceImpl implements IWmsDeliveryWaybillService
// 级联删除发货单明细
if (ids != null && !ids.isEmpty()) {
// 检查是否存在已发货的运单状态为1如果存在则抛出异常
LambdaQueryWrapper<WmsDeliveryWaybill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(WmsDeliveryWaybill::getWaybillId, ids)
.eq(WmsDeliveryWaybill::getStatus, 1);
// 使用 exists 方法替代 selectList提高性能
if (baseMapper.exists(queryWrapper)) {
throw new RuntimeException("已发货的发货单不能删除");
}
// 构建查询条件,查找关联的明细记录
LambdaQueryWrapper<WmsDeliveryWaybillDetail> detailWrapper =
Wrappers.<WmsDeliveryWaybillDetail>lambdaQuery()

View File

@@ -606,8 +606,18 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
if (bo.getMinAbnormalCount() != null) {
qw.apply("COALESCE(ca.abnormal_count, 0) >= {0}", bo.getMinAbnormalCount());
}
//根据创建时间倒叙
qw.orderByDesc("mc.create_time");
// 排序:
// - 当前端需要绑定信息includeBindInfo=true优先展示“已绑定实际库位”的钢卷actual_warehouse_id 非空在前)
// 再按实际库位ID升序库位ID为自增升序即可满足“先生成的库位在前”
// - 否则:保持原有创建时间倒序
if (Boolean.TRUE.equals(bo.getOrderBy())) {
// MySQL: false(0) < true(1),因此 "IS NULL" 升序可实现非空在前、空值在后
qw.orderByAsc("mc.actual_warehouse_id IS NULL");
qw.orderByAsc("mc.actual_warehouse_id");
} else {
//根据创建时间倒叙
qw.orderByDesc("mc.create_time");
}
return qw;
}