|
@@ -0,0 +1,133 @@
|
|
|
|
|
+package com.ydtech.modules.order.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
|
|
|
+import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceMapper;
|
|
|
|
|
+import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceSonMapper;
|
|
|
|
|
+import com.ydtech.modules.order.entity.InsAreaCompany;
|
|
|
|
|
+import com.ydtech.modules.order.entity.InsDrivingIntentionInsurance;
|
|
|
|
|
+import com.ydtech.modules.order.entity.InsDrivingIntentionInsuranceSon;
|
|
|
|
|
+import com.ydtech.modules.order.entity.PtlAgreementNonCarProductRule;
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.InsDrivingIntentionInsuranceVo;
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.NoCarInsuranceQueryVo;
|
|
|
|
|
+import com.ydtech.modules.order.service.InsCrawlerOrderService;
|
|
|
|
|
+import com.ydtech.modules.order.service.InsDrivingIntentionInsuranceService;
|
|
|
|
|
+import com.ydtech.modules.order.service.PtlAgreementNonCarProductRuleService;
|
|
|
|
|
+import com.ydtech.modules.protocol.entity.po.PtlAgreement;
|
|
|
|
|
+import com.ydtech.modules.protocol.service.PtlAgreementService;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 驾意险服务实现类
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDrivingIntentionInsuranceMapper, InsDrivingIntentionInsurance>
|
|
|
|
|
+ implements InsDrivingIntentionInsuranceService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PtlAgreementService ptlAgreementService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private InsDrivingIntentionInsuranceSonMapper sonMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PtlAgreementNonCarProductRuleService ptlAgreementNonCarProductRuleService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据查询条件获取驾意险信息
|
|
|
|
|
+ * @param insuranceVo
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<InsDrivingIntentionInsuranceVo> getInsDrivingIntentionInsuranceVo(NoCarInsuranceQueryVo insuranceVo) {
|
|
|
|
|
+ LambdaQueryWrapper<InsDrivingIntentionInsurance> query = new LambdaQueryWrapper<InsDrivingIntentionInsurance>();
|
|
|
|
|
+
|
|
|
|
|
+ if(insuranceVo.getAgreementId() != null){
|
|
|
|
|
+ PtlAgreement byAgreementIdNew = ptlAgreementService.getByAgreementIdNew(insuranceVo.getAgreementId());
|
|
|
|
|
+ query.eq(InsDrivingIntentionInsurance::getCompanyId, byAgreementIdNew.getInsuranceCompanyId());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ query.eq(InsDrivingIntentionInsurance::getCompanyId, insuranceVo.getCompanyCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(insuranceVo.getSeatNum() != null) {
|
|
|
|
|
+ query.eq(InsDrivingIntentionInsurance::getSeatNum, insuranceVo.getSeatNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> insDrivingIntentionInsurances = baseMapper.selectList(query);
|
|
|
|
|
+ List<String> collect = insDrivingIntentionInsurances.stream().map(InsDrivingIntentionInsurance::getProjectCode).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<InsDrivingIntentionInsuranceSon> insDrivingIntentionInsuranceSons = sonMapper.selectList(new LambdaQueryWrapper<InsDrivingIntentionInsuranceSon>()
|
|
|
|
|
+ .in(InsDrivingIntentionInsuranceSon::getDrivingCodeId, collect));
|
|
|
|
|
+
|
|
|
|
|
+ //组装驾意险信息
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> baseDriving = insDrivingIntentionInsurances.stream().filter(x -> x.getParentId() == 0).collect(Collectors.toList());
|
|
|
|
|
+ List<InsDrivingIntentionInsuranceVo> insDrivingIntentionInsuranceVo = baseDriving.stream()
|
|
|
|
|
+ .map(InsDrivingIntentionInsuranceVo::new)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ insDrivingIntentionInsuranceVo.forEach(x -> {
|
|
|
|
|
+ x.setSon(insDrivingIntentionInsuranceSons.stream().filter(y -> y.getDrivingCodeId().equals(x.getProjectCode())).collect(Collectors.toList()));
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> children = insDrivingIntentionInsurances.stream().filter(y -> y.getParentId() == x.getId()).collect(Collectors.toList());
|
|
|
|
|
+ List<InsDrivingIntentionInsuranceVo> childrenVo = children.stream()
|
|
|
|
|
+ .map(InsDrivingIntentionInsuranceVo::new)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ childrenVo.forEach(y -> {
|
|
|
|
|
+ y.setSon(insDrivingIntentionInsuranceSons.stream().filter(z -> z.getDrivingCodeId().equals(y.getProjectCode())).collect(Collectors.toList()));
|
|
|
|
|
+ });
|
|
|
|
|
+ x.setChildren(childrenVo);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return insDrivingIntentionInsuranceVo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据规则获取驾意险信息
|
|
|
|
|
+ * @param insuranceVo
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<InsDrivingIntentionInsuranceVo> getInsDrivingIntentionInsuranceRule(NoCarInsuranceQueryVo insuranceVo) {
|
|
|
|
|
+ LambdaQueryWrapper<PtlAgreementNonCarProductRule> query = new LambdaQueryWrapper<PtlAgreementNonCarProductRule>();
|
|
|
|
|
+ if(insuranceVo.getCompanyCode() != null){
|
|
|
|
|
+ List<PtlAgreement> byCompanyCode = ptlAgreementService.getByCompanyCode(insuranceVo.getCompanyCode());
|
|
|
|
|
+ List<String> collect = byCompanyCode.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
|
|
+ query.in(PtlAgreementNonCarProductRule::getAgreementId, collect);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ query.eq(PtlAgreementNonCarProductRule::getAgreementId, insuranceVo.getAgreementId());
|
|
|
|
|
+ }
|
|
|
|
|
+ query.le(PtlAgreementNonCarProductRule::getSeatNumMin, insuranceVo.getRuleSeatNum());
|
|
|
|
|
+ query.ge(PtlAgreementNonCarProductRule::getSeatNumMax, insuranceVo.getRuleSeatNum());
|
|
|
|
|
+ query.eq(PtlAgreementNonCarProductRule::getUseNature, insuranceVo.getRuleUseNature());
|
|
|
|
|
+ if(insuranceVo.getRuleThirdPartyInsurance() != null) {
|
|
|
|
|
+ query.ge(PtlAgreementNonCarProductRule::getThirdPartyLnsuranceMin, insuranceVo.getRuleThirdPartyInsurance());
|
|
|
|
|
+ query.le(PtlAgreementNonCarProductRule::getThirdPartyLnsuranceMax, insuranceVo.getRuleThirdPartyInsurance());
|
|
|
|
|
+ }
|
|
|
|
|
+ query.orderBy(true, true, PtlAgreementNonCarProductRule::getSort);
|
|
|
|
|
+ List<PtlAgreementNonCarProductRule> list = ptlAgreementNonCarProductRuleService.list(query);
|
|
|
|
|
+ List<InsDrivingIntentionInsuranceVo> insDrivingIntentionInsuranceVo = getInsDrivingIntentionInsuranceVo(insuranceVo);
|
|
|
|
|
+ if(!list.isEmpty()){
|
|
|
|
|
+ //遍历顶级
|
|
|
|
|
+ insDrivingIntentionInsuranceVo.stream()
|
|
|
|
|
+ .filter(item -> item.getProjectCode().toString().equals(list.get(0).getParentId()))
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .ifPresent(item -> item.setIsDefault(true));
|
|
|
|
|
+ //遍历下级
|
|
|
|
|
+ insDrivingIntentionInsuranceVo.stream()
|
|
|
|
|
+ .flatMap(item -> item.getChildren().stream())
|
|
|
|
|
+ .filter(child -> child.getProjectCode().toString().equals(list.get(0).getProductId()))
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .ifPresent(child -> child.setIsDefault(true));
|
|
|
|
|
+ }
|
|
|
|
|
+ return insDrivingIntentionInsuranceVo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public InsDrivingIntentionInsurance getByParentId(Integer parentId) {
|
|
|
|
|
+ return baseMapper.selectOne(new LambdaQueryWrapper<InsDrivingIntentionInsurance>().eq(InsDrivingIntentionInsurance::getParentId, parentId));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|