fix(oa): 增加代码健壮性
- 在查询发货单详情时增加项目ID空值判断 - 增加订单ID列表空值判断以避免SQL语法错误 - 在查询工艺卡详情时增加项目ID空值判断 - 增加工艺卡ID列表空值判断以防止空查询 - 统一返回空列表的处理方式
This commit is contained in:
@@ -131,12 +131,19 @@ public class OaDeliveryOrderDetailServiceImpl implements IOaDeliveryOrderDetailS
|
||||
|
||||
@Override
|
||||
public List<OaDeliveryOrderDetailVo> queryListByProjectId(Long projectId) {
|
||||
if (projectId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//拿到projectId下的所有orderId
|
||||
LambdaQueryWrapper<OaDeliveryOrder> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(OaDeliveryOrder::getProjectId, projectId);
|
||||
List<OaDeliveryOrder> orderList = oaDeliveryOrderMapper.selectList(wrapper);
|
||||
//然后根据orderId拿到所有的detail
|
||||
List<Long> orderIdList = orderList.stream().map(OaDeliveryOrder::getOrderId).collect(Collectors.toList());
|
||||
// 如果orderIdList为空,则直接返回空列表,避免SQL语法错误
|
||||
if (orderIdList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return baseMapper.selectVoListByOrderIds(orderIdList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.ruoyi.oa.domain.OaProcessCardDetail;
|
||||
import com.ruoyi.oa.mapper.OaProcessCardDetailMapper;
|
||||
import com.ruoyi.oa.service.IOaProcessCardDetailService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
@@ -127,11 +128,18 @@ public class OaProcessCardDetailServiceImpl implements IOaProcessCardDetailServi
|
||||
@Override
|
||||
public List<OaProcessCardDetailVo> queryListByProjectId(Long projectId) {
|
||||
//拿到projectId下的所有cardId
|
||||
if (projectId == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LambdaQueryWrapper<OaProcessCard> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(OaProcessCard::getProjectId, projectId);
|
||||
List<OaProcessCard> cardList = oaProcessCardMapper.selectList(wrapper);
|
||||
//然后根据cardId拿到所有的detail
|
||||
List<Long> cardIdList = cardList.stream().map(OaProcessCard::getCardId).collect(Collectors.toList());
|
||||
//如果cardIdList为空,则直接返回空列表
|
||||
if (cardIdList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return baseMapper.selectVoListByCardIds(cardIdList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user