package com.ydtech.modules.protocols.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ydtech.modules.protocols.dao.PtlAgreementDispatchRulesAttrMapper; import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesAttr; import com.ydtech.modules.protocols.entity.po.PtlAgreementDispatchRulesDictLabal; import com.ydtech.modules.protocols.service.PtlAgreementDispatchRulesAttrService; 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.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @description 协议承保规则属性 service实现类 * @createDate 2024-2-22 15:44:29 * @Entity com.ydtech.modules.protocol.entity.po.PtlAgreementDispatchRulesAttrMapper */ @Service public class PtlAgreementDispatchRulesAttrServiceImpl extends ServiceImpl implements PtlAgreementDispatchRulesAttrService { @Autowired PtlAgreementDispatchRulesDictService ptlAgreementDispatchRulesDictService; @Autowired PtlAgreementDispatchRulesDictLabalService ptlAgreementDispatchRulesDictLabalService; /** * 获取所有规则字典列表 根据保险公司查询 * * @return */ @Override public List getDispatchRulesAttrList(String companyId){ List DispatchRulesDictList = ptlAgreementDispatchRulesDictService.getDispatchRulesDictList(); List list = this.list(new LambdaQueryWrapper().eq(PtlAgreementDispatchRulesAttr::getCompanyIds, "all")); List companyList = this.list(new LambdaQueryWrapper().like(PtlAgreementDispatchRulesAttr::getCompanyIds, companyId)); list.addAll(companyList); list.forEach(attr -> { List listTmp = DispatchRulesDictList.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 getDispatchRulesAttrList(){ List DispatchRulesDictList = ptlAgreementDispatchRulesDictService.getDispatchRulesDictList(); List list = this.list(); list.forEach(attr -> { List listTmp = DispatchRulesDictList.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> getDispatchRulesAttrListType(List DispatchRulesAttrList) { Map> collect = new HashMap<>(); for (PtlAgreementDispatchRulesAttr attr : DispatchRulesAttrList) { if (collect.containsKey(attr.getAttrGroup())) { collect.get(attr.getAttrGroup()).add(attr); } else { List list = new ArrayList<>(); list.add(attr); collect.put(attr.getAttrGroup(), list); } } return collect; } }