fix(order): 优化合同ID查询线圈数据逻辑

- 移除通过订单表间接查询的冗余步骤
- 直接使用合同ID查询线圈合同关联表
- 简化数据库查询逻辑提升性能
- 修复可能的数据查询错误问题
This commit is contained in:
2026-07-05 09:29:05 +08:00
parent 2ab7647bf2
commit 3ffc96b501

View File

@@ -126,7 +126,7 @@ public class CrmOrderItemServiceImpl implements ICrmOrderItemService {
boolean hasCustomerFilter = StringUtils.isNotBlank(bo.getCustomer());
boolean hasSignDateFilter = bo.getSignDateStart() != null || bo.getSignDateEnd() != null;
boolean hasDeliveryDateFilter = bo.getDeliveryDateStart() != null || bo.getDeliveryDateEnd() != null;
if (!hasContractFilter && !hasCustomerFilter && !hasSignDateFilter && !hasDeliveryDateFilter) {
return null;
}
@@ -354,19 +354,8 @@ public class CrmOrderItemServiceImpl implements ICrmOrderItemService {
* @return 逗号分隔的coilId字符串无数据返回null
*/
private String resolveCoilIdsByContractId(Long contractId) {
LambdaQueryWrapper<CrmOrder> orderWrapper = new LambdaQueryWrapper<>();
orderWrapper.eq(CrmOrder::getContractId, contractId);
orderWrapper.eq(CrmOrder::getDelFlag, 0);
List<CrmOrder> orders = crmOrderMapper.selectList(orderWrapper);
if (orders == null || orders.isEmpty()) {
return null;
}
List<Long> orderIds = orders.stream()
.map(CrmOrder::getOrderId)
.collect(Collectors.toList());
LambdaQueryWrapper<WmsCoilContractRel> relWrapper = new LambdaQueryWrapper<>();
relWrapper.in(WmsCoilContractRel::getContractId, orderIds);
relWrapper.eq(WmsCoilContractRel::getContractId, contractId);
relWrapper.eq(WmsCoilContractRel::getDelFlag, 0);
List<WmsCoilContractRel> rels = coilContractRelMapper.selectList(relWrapper);
if (rels == null || rels.isEmpty()) {