PtlAgreementDispatchRulesAttrServiceImpl.java 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package com.ydtech.modules.protocols.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.ydtech.modules.protocols.dao.PtlAgreementDispatchRulesAttrMapper;
  5. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesAttr;
  6. import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDictLabal;
  7. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesAttrService;
  8. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesDictLabalService;
  9. import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesDictService;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. import java.util.stream.Collectors;
  17. /**
  18. * @description 协议承保规则属性 service实现类
  19. * @createDate 2024-2-22 15:44:29
  20. * @Entity com.ydtech.modules.protocol.entity.po.PtlAgreementDispatchRulesAttrMapper
  21. */
  22. @Service
  23. public class PtlAgreementDispatchRulesAttrServiceImpl extends ServiceImpl<PtlAgreementDispatchRulesAttrMapper, PtlAgreementDispatchRulesAttr>
  24. implements PtlAgreementDispatchRulesAttrService {
  25. @Autowired
  26. PtlAgreementDispatchRulesDictService ptlAgreementDispatchRulesDictService;
  27. @Autowired
  28. PtlAgreementDispatchRulesDictLabalService ptlAgreementDispatchRulesDictLabalService;
  29. /**
  30. * 获取所有规则字典列表 根据保险公司查询
  31. *
  32. * @return
  33. */
  34. @Override
  35. public List<PtlAgreementDispatchRulesAttr> getDispatchRulesAttrList(String companyId){
  36. List<PtlAgreementDispatchRulesDictLabal> DispatchRulesDictList = ptlAgreementDispatchRulesDictService.getDispatchRulesDictList();
  37. List<PtlAgreementDispatchRulesAttr> list = this.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttr>().eq(PtlAgreementDispatchRulesAttr::getCompanyIds, "all"));
  38. List<PtlAgreementDispatchRulesAttr> companyList = this.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttr>().like(PtlAgreementDispatchRulesAttr::getCompanyIds, companyId));
  39. list.addAll(companyList);
  40. list.forEach(attr -> {
  41. List<PtlAgreementDispatchRulesDictLabal> listTmp = DispatchRulesDictList.stream().filter(dict -> attr.getDictId() == dict.getDictId()).collect(Collectors.toList());
  42. if(attr.getMinArray() == null)
  43. attr.setMinArray(new String[]{});
  44. if (attr.getDictLabal() == null)
  45. attr.setDictLabal(new ArrayList<>());
  46. attr.setDictLabal(listTmp);
  47. });
  48. return list;
  49. }
  50. /**
  51. * 获取所有规则字典列表
  52. *
  53. * @return
  54. */
  55. @Override
  56. public List<PtlAgreementDispatchRulesAttr> getDispatchRulesAttrList(){
  57. List<PtlAgreementDispatchRulesDictLabal> DispatchRulesDictList = ptlAgreementDispatchRulesDictService.getDispatchRulesDictList();
  58. List<PtlAgreementDispatchRulesAttr> list = this.list();
  59. list.forEach(attr -> {
  60. List<PtlAgreementDispatchRulesDictLabal> listTmp = DispatchRulesDictList.stream().filter(dict -> attr.getDictId() == dict.getDictId()).collect(Collectors.toList());
  61. if(attr.getMinArray() == null)
  62. attr.setMinArray(new String[]{});
  63. if (attr.getDictLabal() == null)
  64. attr.setDictLabal(new ArrayList<>());
  65. attr.setDictLabal(listTmp);
  66. });
  67. return list;
  68. }
  69. @Override
  70. public Map<String, List<PtlAgreementDispatchRulesAttr>> getDispatchRulesAttrListType(List<PtlAgreementDispatchRulesAttr> DispatchRulesAttrList) {
  71. Map<String, List<PtlAgreementDispatchRulesAttr>> collect = new HashMap<>();
  72. for (PtlAgreementDispatchRulesAttr attr : DispatchRulesAttrList) {
  73. if (collect.containsKey(attr.getAttrGroup())) {
  74. collect.get(attr.getAttrGroup()).add(attr);
  75. } else {
  76. List<PtlAgreementDispatchRulesAttr> list = new ArrayList<>();
  77. list.add(attr);
  78. collect.put(attr.getAttrGroup(), list);
  79. }
  80. }
  81. return collect;
  82. }
  83. }