| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package com.ydtech.modules.protocols.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
- import com.ydtech.modules.protocols.dao.PtlAgreementUndwrtRulesAttrMapper;
- import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesDict;
- import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesDictLabal;
- import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesAttrService;
- import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesDictLabalService;
- import com.ydtech.modules.protocols.service.PtlAgreementUndwrtRulesDictService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * @description 协议承保规则属性 service实现类
- * @createDate 2024-2-22 15:44:29
- * @Entity com.ydtech.modules.protocol.entity.po.PtlAgreementUndwrtRulesAttrMapper
- */
- @Service
- public class PtlAgreementUndwrtRulesAttrServiceImpl extends ServiceImpl<PtlAgreementUndwrtRulesAttrMapper, PtlAgreementUndwrtRulesAttr>
- implements PtlAgreementUndwrtRulesAttrService {
- @Autowired
- PtlAgreementUndwrtRulesDictService ptlAgreementUndwrtRulesDictService;
- @Autowired
- PtlAgreementUndwrtRulesDictLabalService ptlAgreementUndwrtRulesDictLabalService;
- /**
- * 获取所有规则字典列表 根据保险公司查询
- *
- * @return
- */
- @Override
- public List<PtlAgreementUndwrtRulesAttr> getUndwrtRulesAttrList(String companyId){
- List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlAgreementUndwrtRulesDictService.getUndwrtRulesDictList();
- List<PtlAgreementUndwrtRulesAttr> list = this.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttr>().eq(PtlAgreementUndwrtRulesAttr::getCompanyIds, "all"));
- List<PtlAgreementUndwrtRulesAttr> companyList = this.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttr>().like(PtlAgreementUndwrtRulesAttr::getCompanyIds, companyId));
- list.addAll(companyList);
- list.forEach(attr -> {
- List<PtlAgreementUndwrtRulesDictLabal> listTmp = undwrtRulesDictList.stream().filter(dict -> attr.getDictId() == dict.getDictId()).collect(Collectors.toList());
- if(attr.getMinArray() == null)
- attr.setMinArray(new String[]{});
- if (attr.getDictLabal() == null)
- attr.setDictLabal(new ArrayList<>());
- attr.setDictLabal(listTmp);
- });
- return list;
- }
- /**
- * 获取所有规则字典列表
- *
- * @return
- */
- @Override
- public List<PtlAgreementUndwrtRulesAttr> getUndwrtRulesAttrList(){
- List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlAgreementUndwrtRulesDictService.getUndwrtRulesDictList();
- List<PtlAgreementUndwrtRulesAttr> list = this.list();
- list.forEach(attr -> {
- List<PtlAgreementUndwrtRulesDictLabal> listTmp = undwrtRulesDictList.stream().filter(dict -> attr.getDictId() == dict.getDictId()).collect(Collectors.toList());
- if(attr.getMinArray() == null)
- attr.setMinArray(new String[]{});
- if (attr.getDictLabal() == null)
- attr.setDictLabal(new ArrayList<>());
- attr.setDictLabal(listTmp);
- });
- return list;
- }
- @Override
- public Map<String, List<PtlAgreementUndwrtRulesAttr>> getUndwrtRulesAttrListType(List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
- Map<String, List<PtlAgreementUndwrtRulesAttr>> collect = new HashMap<>();
- for (PtlAgreementUndwrtRulesAttr attr : undwrtRulesAttrList) {
- if (collect.containsKey(attr.getAttrGroup())) {
- collect.get(attr.getAttrGroup()).add(attr);
- } else {
- List<PtlAgreementUndwrtRulesAttr> list = new ArrayList<>();
- list.add(attr);
- collect.put(attr.getAttrGroup(), list);
- }
- }
- return collect;
- }
- }
|