package com.ydtech.modules.protocols.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ydtech.modules.protocols.dao.PtlAgreementDispatchRulesDictMapper; import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDict; import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDictLabal; import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesDictLabalService; import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesDictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @Author: tz * @description 协议承保规则属性字典 service实现类 * @createDate 2024-2-22 15:44:29 * @Entity com.ydtech.modules.protocol.entity.po.PtlAgreementDispatchRulesdictMapper */ @Service public class PtlAgreementDispatchRulesDictServiceImpl extends ServiceImpl implements PtlAgreementDispatchRulesDictService { @Autowired PtlAgreementDispatchRulesDictLabalService ptlAgreementDispatchRulesDictLabalService; /** * 获取所有规则字典列表 * @return */ @Override public List getDispatchRulesDictList() { List ptlAgreementDispatchRulesDicts = baseMapper.selectList(new QueryWrapper<>(new PtlAgreementDispatchRulesDict())); List list = ptlAgreementDispatchRulesDictLabalService.list(); Map> collect = list.stream().collect(Collectors.groupingBy(PtlAgreementDispatchRulesDictLabal::getParentId)); list = collect.get(0); for(Map.Entry> map : collect.entrySet()){ Integer key = map.getKey(); List value = map.getValue(); list.stream().filter(x -> x.getId() == key).forEach(x -> x.setChildren(value)); } return list; } }