PtlAgreementUndwrtRulesAttrServiceImpl.java 4.1 KB

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