|
|
@@ -4,14 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.modules.order.dao.InsBusinessInsuranceMapper;
|
|
|
import com.ydtech.modules.order.entity.*;
|
|
|
import com.ydtech.modules.order.service.*;
|
|
|
-import com.ydtech.modules.scheme.entity.vo.InsDrivingIntentionInsuranceInfoVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 驾意险服务实现类
|
|
|
@@ -27,32 +24,4 @@ public class InsBusinessInsuranceServiceImpl extends ServiceImpl<InsBusinessInsu
|
|
|
return baseMapper.getBusinessInsurance();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<InsDrivingIntentionInsurance> getDrivingInfo(InsDrivingIntentionInsuranceInfoVo insuranceInfoVo) {
|
|
|
- // 获取所有记录
|
|
|
- List<InsDrivingIntentionInsurance> allRecords = insDrivingIntentionInsuranceService.list();
|
|
|
-
|
|
|
- // 使用parentId对记录进行分组
|
|
|
- Map<Integer, List<InsDrivingIntentionInsurance>> groupedByParent = allRecords.stream()
|
|
|
- .collect(Collectors.groupingBy(InsDrivingIntentionInsurance::getParentId));
|
|
|
-
|
|
|
- // 创建一个新的List来存储最终的结果
|
|
|
- List<InsDrivingIntentionInsurance> resultList = new ArrayList<>();
|
|
|
-
|
|
|
- // 过滤出所有的顶级记录(parentId为null或0)
|
|
|
- List<InsDrivingIntentionInsurance> topLevelRecords = allRecords.stream()
|
|
|
- .filter(item -> item.getParentId() == null || item.getParentId() == 0)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- // 设置每个顶级记录的子记录
|
|
|
- for (InsDrivingIntentionInsurance item : topLevelRecords) {
|
|
|
- // 根据顶级记录的id来查找子记录
|
|
|
- item.setInsDrivingIntentionInsurances(groupedByParent.getOrDefault(item.getId(), new ArrayList<>()));
|
|
|
- }
|
|
|
-
|
|
|
- // 将顶级记录添加到结果集中
|
|
|
- resultList.addAll(topLevelRecords);
|
|
|
-
|
|
|
- return resultList;
|
|
|
- }
|
|
|
}
|