|
@@ -1,14 +1,17 @@
|
|
|
package com.ydtech.modules.order.service.impl;
|
|
package com.ydtech.modules.order.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.constants.enums.InsuranceRisk;
|
|
import com.ydtech.constants.enums.InsuranceRisk;
|
|
|
import com.ydtech.constants.enums.dict.agreement.ProductsType;
|
|
import com.ydtech.constants.enums.dict.agreement.ProductsType;
|
|
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.exception.SystemException;
|
|
import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceMapper;
|
|
import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceMapper;
|
|
|
import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceSonMapper;
|
|
import com.ydtech.modules.order.dao.InsDrivingIntentionInsuranceSonMapper;
|
|
|
import com.ydtech.modules.order.entity.*;
|
|
import com.ydtech.modules.order.entity.*;
|
|
|
import com.ydtech.modules.order.entity.api.pingan.request.ProductDetailsRequest;
|
|
import com.ydtech.modules.order.entity.api.pingan.request.ProductDetailsRequest;
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.InsDrivingIntentionInsuranceSonVo;
|
|
|
import com.ydtech.modules.order.entity.vo.InsDrivingIntentionInsuranceVo;
|
|
import com.ydtech.modules.order.entity.vo.InsDrivingIntentionInsuranceVo;
|
|
|
import com.ydtech.modules.order.entity.vo.NoCarInsuranceQueryVo;
|
|
import com.ydtech.modules.order.entity.vo.NoCarInsuranceQueryVo;
|
|
|
import com.ydtech.modules.order.service.*;
|
|
import com.ydtech.modules.order.service.*;
|
|
@@ -22,6 +25,7 @@ import com.ydtech.modules.scheme.service.PtlOptionalSchemeInsuranceDrivingIntent
|
|
|
import com.ydtech.modules.scheme.service.PtlOptionalSchemeService;
|
|
import com.ydtech.modules.scheme.service.PtlOptionalSchemeService;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
import com.ydtech.utils.StringUtils;
|
|
|
import com.ydtech.modules.scheme.entity.vo.DrivingIntentionQueryVo;
|
|
import com.ydtech.modules.scheme.entity.vo.DrivingIntentionQueryVo;
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -64,6 +68,9 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PtlOptionalSchemeInsuranceDrivingIntentionService ptlOptionalSchemeInsuranceDrivingIntentionService;
|
|
private PtlOptionalSchemeInsuranceDrivingIntentionService ptlOptionalSchemeInsuranceDrivingIntentionService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private InsDrivingIntentionInsuranceSonService insDrivingIntentionInsuranceSonService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PtlOptionalSchemeService ptlOptionalSchemeService;
|
|
private PtlOptionalSchemeService ptlOptionalSchemeService;
|
|
|
|
|
|
|
@@ -366,4 +373,138 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
|
|
|
|
|
|
|
|
return rootNodes;
|
|
return rootNodes;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 新增驾意险
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult add(InsDrivingIntentionInsuranceVo insDrivingIntentionInsuranceVo) {
|
|
|
|
|
+ InsDrivingIntentionInsurance insDrivingIntentionInsurance = new InsDrivingIntentionInsurance();
|
|
|
|
|
+ BeanUtils.copyProperties(insDrivingIntentionInsuranceVo, insDrivingIntentionInsurance);
|
|
|
|
|
+ baseMapper.insert(insDrivingIntentionInsurance);
|
|
|
|
|
+ return HttpResult.ok("新增成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult addSon(InsDrivingIntentionInsuranceSonVo insDrivingIntentionInsuranceSonVo) {
|
|
|
|
|
+ InsDrivingIntentionInsuranceSon insDrivingIntentionInsuranceSon = new InsDrivingIntentionInsuranceSon();
|
|
|
|
|
+ BeanUtils.copyProperties(insDrivingIntentionInsuranceSonVo, insDrivingIntentionInsuranceSon);
|
|
|
|
|
+ insDrivingIntentionInsuranceSonService.save(insDrivingIntentionInsuranceSon);
|
|
|
|
|
+ return HttpResult.ok("新增成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //修改驾意险
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult update(InsDrivingIntentionInsurance insDrivingIntentionInsurance) {
|
|
|
|
|
+ InsDrivingIntentionInsurance insDrivingIntentionInsurance1 = baseMapper.selectById(insDrivingIntentionInsurance.getId());
|
|
|
|
|
+ if (insDrivingIntentionInsurance1 == null) {
|
|
|
|
|
+ return HttpResult.error("修改失败,数据不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ baseMapper.updateById(insDrivingIntentionInsurance);
|
|
|
|
|
+ return HttpResult.ok("修改成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult updateSon(InsDrivingIntentionInsuranceSon insDrivingIntentionInsuranceSon) {
|
|
|
|
|
+ InsDrivingIntentionInsuranceSon insDrivingIntentionInsuranceSon1 = sonMapper.selectById(insDrivingIntentionInsuranceSon.getSonId());
|
|
|
|
|
+ if (insDrivingIntentionInsuranceSon1 == null) {
|
|
|
|
|
+ return HttpResult.error("修改失败,数据不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ insDrivingIntentionInsuranceSon.setId(insDrivingIntentionInsuranceSon.getSonId());
|
|
|
|
|
+ insDrivingIntentionInsuranceSonService.updateById(insDrivingIntentionInsuranceSon);
|
|
|
|
|
+ return HttpResult.ok("修改成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //删除驾意险
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult delete(InsDrivingIntentionInsurance insDrivingIntentionInsurance) {
|
|
|
|
|
+ InsDrivingIntentionInsurance insDrivingIntentionInsurance1 = baseMapper.selectById(insDrivingIntentionInsurance.getId());
|
|
|
|
|
+ if (insDrivingIntentionInsurance1 == null) {
|
|
|
|
|
+ return HttpResult.error("删除失败,数据不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ baseMapper.deleteById(insDrivingIntentionInsurance);
|
|
|
|
|
+ List<InsDrivingIntentionInsuranceSon> insDrivingIntentionInsuranceSonList = sonMapper.selectList(new LambdaQueryWrapper<InsDrivingIntentionInsuranceSon>().eq(InsDrivingIntentionInsuranceSon::getProductCode, insDrivingIntentionInsurance.getProjectCode()));
|
|
|
|
|
+ if (insDrivingIntentionInsuranceSonList != null && insDrivingIntentionInsuranceSonList.size() > 0) {
|
|
|
|
|
+ insDrivingIntentionInsuranceSonService.removeBatchByIds(insDrivingIntentionInsuranceSonList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok("删除成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpResult deleteSon(InsDrivingIntentionInsuranceSon insDrivingIntentionInsuranceSon) {
|
|
|
|
|
+ InsDrivingIntentionInsuranceSon insDrivingIntentionInsuranceSon1 = sonMapper.selectById(insDrivingIntentionInsuranceSon.getSonId());
|
|
|
|
|
+ if ( insDrivingIntentionInsuranceSon1 == null) {
|
|
|
|
|
+ return HttpResult.error("删除失败,数据不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ insDrivingIntentionInsuranceSon.setId(insDrivingIntentionInsuranceSon.getSonId());
|
|
|
|
|
+ sonMapper.deleteById(insDrivingIntentionInsuranceSon);
|
|
|
|
|
+ return HttpResult.ok("删除成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Page<InsDrivingIntentionInsurance> getSchemeDrivingIntentionInsuranceList(Page page,DrivingIntentionQueryVo drivingIntentionQueryVo){
|
|
|
|
|
+ LambdaQueryWrapper<InsDrivingIntentionInsurance> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ //保险公司id
|
|
|
|
|
+ if(!Objects.isNull(drivingIntentionQueryVo.getCompanyId())){
|
|
|
|
|
+ queryWrapper.eq(InsDrivingIntentionInsurance::getCompanyId, drivingIntentionQueryVo.getCompanyId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!Objects.isNull(drivingIntentionQueryVo.getProductName())) {
|
|
|
|
|
+ queryWrapper.like(InsDrivingIntentionInsurance::getProjectName, drivingIntentionQueryVo.getProductName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //座位数
|
|
|
|
|
+ if(!Objects.isNull(drivingIntentionQueryVo.getSeatNum())){
|
|
|
|
|
+ queryWrapper.eq(InsDrivingIntentionInsurance::getSeatNum, drivingIntentionQueryVo.getSeatNum());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(!Objects.isNull(drivingIntentionQueryVo.getDrivingIntentionIds())){
|
|
|
|
|
+ queryWrapper.in(InsDrivingIntentionInsurance::getId,drivingIntentionQueryVo.getDrivingIntentionIds());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //自选方案
|
|
|
|
|
+ if(!Objects.isNull(drivingIntentionQueryVo.getProductId())){
|
|
|
|
|
+ PtlOptionalScheme ptlOptionalScheme = ptlOptionalSchemeService.getOne(new LambdaQueryWrapper<PtlOptionalScheme>()
|
|
|
|
|
+ .eq(PtlOptionalScheme::getCompanyId, drivingIntentionQueryVo.getCompanyId())
|
|
|
|
|
+ .eq(PtlOptionalScheme::getProductId, drivingIntentionQueryVo.getProductId())
|
|
|
|
|
+ .eq(PtlOptionalScheme::getEnergyType,drivingIntentionQueryVo.getEnergyType())
|
|
|
|
|
+ .eq(PtlOptionalScheme::getVehicleType,drivingIntentionQueryVo.getVehicleType())
|
|
|
|
|
+ .eq(PtlOptionalScheme::getCarnature,drivingIntentionQueryVo.getCarnature()));
|
|
|
|
|
+ LambdaQueryWrapper<PtlOptionalSchemeInsuranceDrivingIntention> eq = new LambdaQueryWrapper<PtlOptionalSchemeInsuranceDrivingIntention>()
|
|
|
|
|
+ .eq(PtlOptionalSchemeInsuranceDrivingIntention::getSchemeId, ptlOptionalScheme.getId())
|
|
|
|
|
+ .eq(PtlOptionalSchemeInsuranceDrivingIntention::getSeatNum, drivingIntentionQueryVo.getSeatNum());
|
|
|
|
|
+ List<PtlOptionalSchemeInsuranceDrivingIntention> list = ptlOptionalSchemeInsuranceDrivingIntentionService.list(eq);
|
|
|
|
|
+ List<String> collect = list.stream().map(x -> x.getDrivingIntentionId()).collect(Collectors.toList());
|
|
|
|
|
+ if(collect.isEmpty()){
|
|
|
|
|
+ throw new SystemException("自选方案驾意险为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ drivingIntentionQueryVo.setDrivingIntentionIds(collect);
|
|
|
|
|
+ drivingIntentionQueryVo.setParentId(collect);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> insDrivingIntentionInsurances = new ArrayList<>();
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> list = baseMapper.getInsDrivingIntentionInsuranceList(drivingIntentionQueryVo);
|
|
|
|
|
+
|
|
|
|
|
+ if(!list.isEmpty()) {
|
|
|
|
|
+ //处理父级
|
|
|
|
|
+ if (list.get(0).getParentId() != null && list.get(0).getParentId() != 0) {
|
|
|
|
|
+ List<String> parentIds = list.stream().map(x -> x.getParentId().toString()).collect(Collectors.toList());
|
|
|
|
|
+ LambdaQueryWrapper<InsDrivingIntentionInsurance> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper1.eq(InsDrivingIntentionInsurance::getCompanyId, drivingIntentionQueryVo.getCompanyId())
|
|
|
|
|
+ .in(InsDrivingIntentionInsurance::getId, parentIds);
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> parentInsurance = baseMapper.selectList(queryWrapper1);
|
|
|
|
|
+ list.addAll(parentInsurance);
|
|
|
|
|
+ }
|
|
|
|
|
+ insDrivingIntentionInsurances = this.buildHierarchy(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int currentPage = drivingIntentionQueryVo.getPageNum();
|
|
|
|
|
+ int pageSize = drivingIntentionQueryVo.getPageSize();
|
|
|
|
|
+ int fromIndex = (currentPage - 1) * pageSize; // 计算起始索引
|
|
|
|
|
+ int toIndex = Math.min(fromIndex + pageSize, insDrivingIntentionInsurances.size()); // 计算结束索引
|
|
|
|
|
+
|
|
|
|
|
+ List<InsDrivingIntentionInsurance> paginatedData = insDrivingIntentionInsurances.subList(fromIndex, toIndex);
|
|
|
|
|
+ Page page1 = new Page(currentPage, pageSize, insDrivingIntentionInsurances.size(), true);
|
|
|
|
|
+ page1.setRecords(paginatedData);
|
|
|
|
|
+ return page1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|