| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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<PtlAgreementDispatchRulesAttrMapper, PtlAgreementDispatchRulesAttr>
- implements PtlAgreementDispatchRulesAttrService {
- @Autowired
- PtlAgreementDispatchRulesDictService ptlAgreementDispatchRulesDictService;
- @Autowired
- PtlAgreementDispatchRulesDictLabalService ptlAgreementDispatchRulesDictLabalService;
- /**
- * 获取所有规则字典列表 根据保险公司查询
- *
- * @return
- */
- @Override
- public List<PtlAgreementDispatchRulesAttr> getDispatchRulesAttrList(String companyId){
- List<PtlAgreementDispatchRulesDictLabal> DispatchRulesDictList = ptlAgreementDispatchRulesDictService.getDispatchRulesDictList();
- List<PtlAgreementDispatchRulesAttr> list = this.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttr>().eq(PtlAgreementDispatchRulesAttr::getCompanyIds, "all"));
- List<PtlAgreementDispatchRulesAttr> companyList = this.list(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttr>().like(PtlAgreementDispatchRulesAttr::getCompanyIds, companyId));
- list.addAll(companyList);
- list.forEach(attr -> {
- List<PtlAgreementDispatchRulesDictLabal> 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<PtlAgreementDispatchRulesAttr> getDispatchRulesAttrList(){
- List<PtlAgreementDispatchRulesDictLabal> DispatchRulesDictList = ptlAgreementDispatchRulesDictService.getDispatchRulesDictList();
- List<PtlAgreementDispatchRulesAttr> list = this.list();
- list.forEach(attr -> {
- List<PtlAgreementDispatchRulesDictLabal> 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<String, List<PtlAgreementDispatchRulesAttr>> getDispatchRulesAttrListType(List<PtlAgreementDispatchRulesAttr> DispatchRulesAttrList) {
- Map<String, List<PtlAgreementDispatchRulesAttr>> collect = new HashMap<>();
- for (PtlAgreementDispatchRulesAttr attr : DispatchRulesAttrList) {
- if (collect.containsKey(attr.getAttrGroup())) {
- collect.get(attr.getAttrGroup()).add(attr);
- } else {
- List<PtlAgreementDispatchRulesAttr> list = new ArrayList<>();
- list.add(attr);
- collect.put(attr.getAttrGroup(), list);
- }
- }
- return collect;
- }
- }
|