Commit 1009bb96 authored by 李灿灿's avatar 李灿灿

fix:减少一次数据库查询,减少接口响应时间

parent ce460b53
package com.yifu.cloud.plus.v1.yifu.insurances.vo; package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
...@@ -92,4 +93,10 @@ public class InsuranceInsuredParam implements Serializable { ...@@ -92,4 +93,10 @@ public class InsuranceInsuredParam implements Serializable {
*/ */
@Schema(description = "错误信息") @Schema(description = "错误信息")
private String errorMessage; private String errorMessage;
/**
* 数据传递对象
*/
@JsonIgnore
private TInsuranceDetail detail;
} }
package com.yifu.cloud.plus.v1.yifu.insurances.vo; package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
...@@ -68,4 +70,10 @@ public class InsuranceRegisterInvoiceNoParam implements Serializable { ...@@ -68,4 +70,10 @@ public class InsuranceRegisterInvoiceNoParam implements Serializable {
*/ */
@Schema(description = "错误信息") @Schema(description = "错误信息")
private String errorMessage; private String errorMessage;
/**
* 数据传递对象
*/
@JsonIgnore
private TInsuranceDetail detail;
} }
package com.yifu.cloud.plus.v1.yifu.insurances.vo; package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
...@@ -80,4 +82,10 @@ public class InsuranceRegisterParam implements Serializable { ...@@ -80,4 +82,10 @@ public class InsuranceRegisterParam implements Serializable {
*/ */
@Schema(description = "错误信息") @Schema(description = "错误信息")
private String errorMessage; private String errorMessage;
/**
* 数据传递对象
*/
@JsonIgnore
private TInsuranceDetail detail;
} }
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.insurances.vo; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
...@@ -100,6 +101,12 @@ public class InsuranceReplaceParam implements Serializable { ...@@ -100,6 +101,12 @@ public class InsuranceReplaceParam implements Serializable {
@Schema(description = "错误信息") @Schema(description = "错误信息")
private String errorMessage; private String errorMessage;
/**
* 数据传递对象
*/
@JsonIgnore
private TInsuranceDetail detail;
/***********************************以下字段由系统算出,前端不用传,是为了方便入库***********************************/ /***********************************以下字段由系统算出,前端不用传,是为了方便入库***********************************/
/** /**
* 结算类型 (1、单独结算 2、合并结算-和工资一起结算) * 结算类型 (1、单独结算 2、合并结算-和工资一起结算)
......
...@@ -466,24 +466,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -466,24 +466,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//替换 //替换
TInsuranceDetail newDetail = new TInsuranceDetail(); TInsuranceDetail newDetail = new TInsuranceDetail();
//原数据置为无效:姓名 + 身份证号 + 项目编码 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间 + 购买标准 + 有效 //原数据置为无效:姓名 + 身份证号 + 项目编码 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间 + 购买标准 + 有效
TInsuranceDetail detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda() TInsuranceDetail detail = success.getDetail();
.eq(TInsuranceDetail::getEmpName, success.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, success.getEmpIdcardNo())
.eq(TInsuranceDetail::getDeptNo, success.getDeptNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, success.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, success.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, LocalDateUtil.parseLocalDate(success.getPolicyStart()))
.eq(TInsuranceDetail::getPolicyEnd, LocalDateUtil.parseLocalDate(success.getPolicyEnd()))
.eq(TInsuranceDetail::getBuyStandard, success.getBuyStandard())
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
//有效
.and(
wrapper -> wrapper.eq(TInsuranceDetail::getIsEffect,CommonConstants.ZERO_INT)
.or().isNull(TInsuranceDetail::getIsEffect)
)
.orderByDesc(TInsuranceDetail::getUpdateTime)
.last(CommonConstants.LAST_ONE_SQL)
);
BeanCopyUtils.copyProperties(detail,newDetail); BeanCopyUtils.copyProperties(detail,newDetail);
detail.setIsEffect(CommonConstants.ONE_INT); detail.setIsEffect(CommonConstants.ONE_INT);
detail.setIsOverdue(null); detail.setIsOverdue(null);
...@@ -1756,20 +1739,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -1756,20 +1739,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
for (InsuranceRegisterParam success : listSuccess) { for (InsuranceRegisterParam success : listSuccess) {
//登记保单保费 //登记保单保费
//查数据:姓名 + 身份证号 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间 + 购买标准 //查数据:姓名 + 身份证号 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间 + 购买标准
TInsuranceDetail detail = baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda() TInsuranceDetail detail = success.getDetail();
.eq(TInsuranceDetail::getEmpName, success.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, success.getEmpIdcardNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, success.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, success.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, LocalDateUtil.parseLocalDate(success.getPolicyStart()))
.eq(TInsuranceDetail::getPolicyEnd, LocalDateUtil.parseLocalDate(success.getPolicyEnd()))
.eq(TInsuranceDetail::getBuyStandard, success.getBuyStandard())
//排除替换类型,解决保单保费挂靠问题
.ne(TInsuranceDetail::getBuyType,CommonConstants.FOUR_INT)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
.orderByDesc(TInsuranceDetail::getUpdateTime)
.last(CommonConstants.LAST_ONE_SQL)
);
actualMoney = detail.getActualPremium(); actualMoney = detail.getActualPremium();
if (StringUtils.isNotBlank(success.getInvoiceNo())){ if (StringUtils.isNotBlank(success.getInvoiceNo())){
detail.setInvoiceNo(success.getInvoiceNo()); detail.setInvoiceNo(success.getInvoiceNo());
...@@ -2046,22 +2016,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -2046,22 +2016,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
List<TInsuranceDetail> detailList = new ArrayList<>(); List<TInsuranceDetail> detailList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(listSuccess)){ if (CollectionUtils.isNotEmpty(listSuccess)){
for (InsuranceRegisterInvoiceNoParam success : listSuccess) { for (InsuranceRegisterInvoiceNoParam success : listSuccess) {
TInsuranceDetail detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda() TInsuranceDetail detail = success.getDetail();
.eq(TInsuranceDetail::getEmpName, success.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, success.getEmpIdcardNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, success.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, success.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, LocalDateUtil.parseLocalDate(success.getPolicyStart()))
.eq(TInsuranceDetail::getPolicyEnd, LocalDateUtil.parseLocalDate(success.getPolicyEnd()))
.eq(TInsuranceDetail::getBuyStandard,success.getBuyStandard())
//排除替换类型
.ne(TInsuranceDetail::getBuyType,CommonConstants.FOUR_INT)
//只查询已投保和已减员的
.in(TInsuranceDetail::getBuyHandleStatus,CommonConstants.THREE_INT,CommonConstants.FIVE_INT)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
.orderByDesc(TInsuranceDetail::getUpdateTime)
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(detail).isPresent()){ if (Optional.ofNullable(detail).isPresent()){
//当两次发票号不一致时才更新 //当两次发票号不一致时才更新
if (!success.getInvoiceNo().equals(detail.getInvoiceNo())){ if (!success.getInvoiceNo().equals(detail.getInvoiceNo())){
...@@ -2161,20 +2116,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -2161,20 +2116,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
List<TInsuranceDetail> detailList = new ArrayList<>(); List<TInsuranceDetail> detailList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(listSuccess)){ if (CollectionUtils.isNotEmpty(listSuccess)){
for (InsuranceInsuredParam success : listSuccess) { for (InsuranceInsuredParam success : listSuccess) {
TInsuranceDetail detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda() TInsuranceDetail detail = success.getDetail();
.eq(TInsuranceDetail::getEmpName, success.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, success.getEmpIdcardNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, success.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, success.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, LocalDateUtil.parseLocalDate(success.getPolicyStart()))
.eq(TInsuranceDetail::getPolicyEnd, LocalDateUtil.parseLocalDate(success.getPolicyEnd()))
.eq(TInsuranceDetail::getBuyStandard,success.getBuyStandard())
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
//只查询已投保和已减员的
.in(TInsuranceDetail::getBuyHandleStatus,CommonConstants.THREE_INT,CommonConstants.FIVE_INT)
.orderByDesc(TInsuranceDetail::getUpdateTime)
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(detail).isPresent()){ if (Optional.ofNullable(detail).isPresent()){
TInsuranceDetail oldDetail = new TInsuranceDetail(); TInsuranceDetail oldDetail = new TInsuranceDetail();
BeanCopyUtils.copyProperties(detail,oldDetail); BeanCopyUtils.copyProperties(detail,oldDetail);
...@@ -3376,6 +3318,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -3376,6 +3318,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
continue; continue;
} }
//所有校验通过后设置查到的结果
param.setDetail(detail);
listSuccess.add(param); listSuccess.add(param);
} }
map.put("listResult",listResult); map.put("listResult",listResult);
...@@ -3624,6 +3568,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -3624,6 +3568,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
} }
} }
param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS); param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS);
//所有校验通过后设置查到的结果
param.setDetail(detail);
} }
return paramList.stream().distinct().collect(Collectors.toList()); return paramList.stream().distinct().collect(Collectors.toList());
} }
...@@ -3717,6 +3663,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -3717,6 +3663,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
} }
} }
param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS); param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS);
//所有校验通过后设置查到的结果
param.setDetail(detail);
} }
return collect; return collect;
} }
...@@ -3854,6 +3802,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -3854,6 +3802,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
} }
} }
param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS); param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS);
//所有校验通过后设置查到的结果
param.setDetail(detail);
} }
return collect; return collect;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment