PtlAgreementDispatchRulesDictServiceImpl.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.ydtech.modules.protocols.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.ydtech.modules.protocols.dao.PtlAgreementDispatchRulesDictMapper;
  5. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDict;
  6. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDictLabal;
  7. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesDictLabalService;
  8. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesDictService;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import java.util.List;
  12. import java.util.Map;
  13. import java.util.stream.Collectors;
  14. /**
  15. * @Author: tz
  16. * @description 协议承保规则属性字典 service实现类
  17. * @createDate 2024-2-22 15:44:29
  18. * @Entity com.ydtech.modules.protocol.entity.po.PtlAgreementDispatchRulesdictMapper
  19. */
  20. @Service
  21. public class PtlAgreementDispatchRulesDictServiceImpl extends ServiceImpl<PtlAgreementDispatchRulesDictMapper, PtlAgreementDispatchRulesDict>
  22. implements PtlAgreementDispatchRulesDictService {
  23. @Autowired
  24. PtlAgreementDispatchRulesDictLabalService ptlAgreementDispatchRulesDictLabalService;
  25. /**
  26. * 获取所有规则字典列表
  27. * @return
  28. */
  29. @Override
  30. public List<PtlAgreementDispatchRulesDictLabal> getDispatchRulesDictList() {
  31. List<PtlAgreementDispatchRulesDict> ptlAgreementDispatchRulesDicts = baseMapper.selectList(new QueryWrapper<>(new PtlAgreementDispatchRulesDict()));
  32. List<PtlAgreementDispatchRulesDictLabal> list = ptlAgreementDispatchRulesDictLabalService.list();
  33. Map<Integer,List<PtlAgreementDispatchRulesDictLabal>> collect = list.stream().collect(Collectors.groupingBy(PtlAgreementDispatchRulesDictLabal::getParentId));
  34. list = collect.get(0);
  35. for(Map.Entry<Integer, List<PtlAgreementDispatchRulesDictLabal>> map : collect.entrySet()){
  36. Integer key = map.getKey();
  37. List<PtlAgreementDispatchRulesDictLabal> value = map.getValue();
  38. list.stream().filter(x -> x.getId() == key).forEach(x -> x.setChildren(value));
  39. }
  40. return list;
  41. }
  42. }