Commit 6222b37d authored by huyuchen's avatar huyuchen

商险优化修改

parent e6f2ca8c
......@@ -1743,16 +1743,21 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
TSettleDomain settleDomain;
if (CollectionUtils.isNotEmpty(listSuccess)){
TInsuranceDetail detail;
List<TInsuranceReplace> list;
List<TInsuranceReplace> replaceList;
TInsuranceSettle settle;
for (InsuranceRegisterParam success : listSuccess) {
long d1 = System.currentTimeMillis();
//登记保单保费
//查数据:姓名 + 身份证号 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间 + 购买标准
TInsuranceDetail detail = success.getDetail();
detail = success.getDetail();
actualMoney = detail.getActualPremium();
if (StringUtils.isNotBlank(success.getInvoiceNo())){
detail.setInvoiceNo(success.getInvoiceNo());
//如果发票号不为空,将替换类型的发票号也全部更新
List<TInsuranceReplace> list = tInsuranceReplaceService.list(Wrappers.<TInsuranceReplace>query().lambda()
list = tInsuranceReplaceService.list(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getOriginInsuranceDetailId, detail.getId()));
if (CollectionUtils.isNotEmpty(list)){
List<String> collect = list.stream().map(TInsuranceReplace::getToInsuranceDetailId).distinct().collect(Collectors.toList());
......@@ -1768,7 +1773,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setUpdateTime(LocalDateTime.now());
//如果当前为合并结算,判断预估是否已发送
if(StringUtils.isNotBlank(detail.getDefaultSettleId()) && detail.getSettleType() == CommonConstants.ZERO_INT){
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
//如果未推送则推送预估新增
if(CommonConstants.ZERO_INT == settle.getIsEstimatePush()){
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.ONE_INT);
......@@ -1786,10 +1791,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
tInsurancePolicyService.saveTInsurancePolicy(policy);
//如果保单号不为空,将替换类型的保单号也全部更新
List<TInsuranceReplace> list = tInsuranceReplaceService.list(Wrappers.<TInsuranceReplace>query().lambda()
replaceList = tInsuranceReplaceService.list(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getOriginInsuranceDetailId, detail.getId()));
if (CollectionUtils.isNotEmpty(list)){
List<String> collect = list.stream().map(TInsuranceReplace::getToInsuranceDetailId).distinct().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(replaceList)){
List<String> collect = replaceList.stream().map(TInsuranceReplace::getToInsuranceDetailId).distinct().collect(Collectors.toList());
List<InsuranceUpdateVO> details = baseMapper.selectByIds(collect);
if (CollectionUtils.isNotEmpty(details)){
details.forEach(e -> e.setPolicyNo(success.getPolicyNo()));
......@@ -1801,11 +1806,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//如果保费不为空
if (StringUtils.isNotBlank(success.getActualPremium())){
BigDecimal bigDecimalAct = new BigDecimal(success.getActualPremium());
Integer settleType = detail.getSettleType();
String defaultSettleId = detail.getDefaultSettleId();
//如果当前保单为合并结算
if (settleType == CommonConstants.ZERO_INT && StringUtils.isNotBlank(defaultSettleId)) {
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (detail.getSettleType() == CommonConstants.ZERO_INT &&
StringUtils.isNotBlank(detail.getDefaultSettleId())) {
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()) {
Integer isActualPush = settle.getIsActualPush();
//如果当前实缴信息未推送,则新增实缴单推送
......@@ -1832,13 +1836,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
}
//如果当前保单为单独结算
} else if(settleType == CommonConstants.ONE_INT){
} else if(detail.getSettleType() == CommonConstants.ONE_INT){
//推送过实缴信息且金额与本次不一致,则推送更新
boolean c = !Common.isNotNull(detail.getActualPremium()) ||
bigDecimalAct.compareTo(detail.getActualPremium()) != 0;
if(StringUtils.isNotBlank(defaultSettleId) && c){
if(StringUtils.isNotBlank(detail.getDefaultSettleId()) && c){
//推送保费更新
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle.setActualPremium(bigDecimalAct);
settle.setIsActualPush(CommonConstants.ZERO_INT);
settle.setUpdateTime(LocalDateTime.now());
......@@ -1847,9 +1851,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setActualPremium(bigDecimalAct);
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.FOUR_INT);
//未推送过实缴信息,则推送新增
} else if(StringUtils.isBlank(defaultSettleId)){
} else if(StringUtils.isBlank(detail.getDefaultSettleId())){
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
......@@ -1865,28 +1869,24 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
}
}
String invoiceNo = success.getInvoiceNo();
String policyNo = success.getPolicyNo();
boolean booleanInvoiceNo = StringUtils.isNotBlank(invoiceNo) && !invoiceNo.equals(detail.getInvoiceNo());
boolean booleanPolicyNo = StringUtils.isNotBlank(policyNo) && !policyNo.equals(detail.getPolicyNo());
boolean booleanInvoiceNo = StringUtils.isNotBlank(success.getInvoiceNo()) && !success.getInvoiceNo().equals(detail.getInvoiceNo());
boolean booleanPolicyNo = StringUtils.isNotBlank(success.getPolicyNo()) && !success.getPolicyNo().equals(detail.getPolicyNo());
boolean isEquals = Common.isNotNull(detail.getActualPremium()) && Common.isNotNull(success.getActualPremium()) && new BigDecimal(success.getActualPremium()).compareTo(detail.getActualPremium()) == 0;
//如果当前保费为空,且保单号或发票号不一样
if ((StringUtils.isBlank(success.getActualPremium()) || isEquals) && (booleanInvoiceNo || booleanPolicyNo)
&& StringUtils.isNotBlank(detail.getDefaultSettleId())) {
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()) {
//如果当前实缴信息未推送,则新增实缴单推送
if (StringUtils.isNotBlank(invoiceNo)) {
detail.setInvoiceNo(invoiceNo);
if (StringUtils.isNotBlank(success.getInvoiceNo())) {
detail.setInvoiceNo(success.getInvoiceNo());
}
if (StringUtils.isNotBlank(policyNo)) {
detail.setPolicyNo(policyNo);
if (StringUtils.isNotBlank(success.getPolicyNo())) {
detail.setPolicyNo(success.getPolicyNo());
}
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.FOUR_INT);
}
}
//可以改成批量更新
this.updateById(detail);
detailList.add(detail);
try {
//获取项目信息
......@@ -1982,6 +1982,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
mapSelectVo.clear();
//操作记录
if (!detailList.isEmpty()) {
this.updateBatchById(detailList);
}
addOperate(detailList,user,InsurancesConstants.REGISTERED,null,CommonConstants.ONE_INT);
if (operatList.stream().allMatch(e->e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS))) {
operatList = null;
......@@ -3383,10 +3386,16 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
*/
private List<InsuranceRegisterParam> registeredPolicyPremiumCheck(List<InsuranceRegisterParam> paramList,List<TInsuranceAreaRes> insuranceAreaResList){
List<InsuranceRegisterParam> distinctList = paramList.stream().distinct().collect(Collectors.toList());
//定义外层循环标识,方便去重的时候跳出
outer:
TInsuranceDetail detail;
TInsurancePolicy addPolicyNo;
TInsurancePolicy batchPolicyNo;
TInsuranceSettle settle;
Map<String,String> map = new HashMap<>();
InsuranceRegisterParam param;
SettleVo settleVo;
for (int i = 0; i < distinctList.size(); i++) {
InsuranceRegisterParam param = distinctList.get(i);
param = distinctList.get(i);
// 必填校验
if (StringUtils.isBlank(param.getEmpName())){
param.setErrorMessage(InsurancesConstants.EMP_NAME_NOT_EMPTY);
......@@ -3424,42 +3433,37 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
param.setErrorMessage(InsurancesConstants.BUY_STANDARD_NOT_EMPTY);
continue;
}
if (StringUtils.isNotBlank(param.getPolicyNo())){
if (!ValidityUtil.validate50(param.getPolicyNo())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_MORE_THAN_50);
continue;
}
if (StringUtils.isNotBlank(param.getPolicyNo()) && !ValidityUtil.validate50(param.getPolicyNo())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_MORE_THAN_50);
continue;
}
if (StringUtils.isNotBlank(param.getActualPremium())){
if(!ValidityUtil.validateMoney(param.getActualPremium())){
param.setErrorMessage(InsurancesConstants.ACTUAL_PREMIUM_PARSE_ERROR);
continue;
}
if (StringUtils.isNotBlank(param.getActualPremium()) && !ValidityUtil.validateMoney(param.getActualPremium())) {
param.setErrorMessage(InsurancesConstants.ACTUAL_PREMIUM_PARSE_ERROR);
continue;
}
if (StringUtils.isNotBlank(param.getInvoiceNo())){
if (!ValidityUtil.validate50(param.getInvoiceNo())){
param.setErrorMessage(InsurancesConstants.INVOICE_NO_MORE_THAN_50);
continue;
}
if (StringUtils.isNotBlank(param.getInvoiceNo()) && !ValidityUtil.validate50(param.getInvoiceNo())){
param.setErrorMessage(InsurancesConstants.INVOICE_NO_MORE_THAN_50);
continue;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间、购买标准
for (int j = 0; j < distinctList.size(); j++) {
InsuranceRegisterParam repeat = distinctList.get(j);
if (param.getEmpName().equals(repeat.getEmpName())
&& param.getEmpIdcardNo().equals(repeat.getEmpIdcardNo())
&& param.getInsuranceCompanyName().equals(repeat.getInsuranceCompanyName())
&& param.getInsuranceTypeName().equals(repeat.getInsuranceTypeName())
&& param.getPolicyStart().equals(repeat.getPolicyStart()) && param.getPolicyEnd().equals(repeat.getPolicyEnd())
&& param.getBuyStandard().equals(repeat.getBuyStandard())
&& i != j){
param.setErrorMessage(InsurancesConstants.DUPLICATE_DATA_ERROR);
continue outer;
}
StringBuilder errorTemp = new StringBuilder();
errorTemp.append(param.getEmpName());
errorTemp.append(param.getEmpIdcardNo());
errorTemp.append(param.getInsuranceCompanyName());
errorTemp.append(param.getInsuranceTypeName());
errorTemp.append(param.getPolicyStart());
errorTemp.append(param.getPolicyEnd());
errorTemp.append(param.getBuyStandard());
if (null == map.get(errorTemp.toString())) {
map.put(errorTemp.toString(),"1");
} else {
param.setErrorMessage(InsurancesConstants.DUPLICATE_DATA_ERROR);
continue;
}
//查数据是否存在:姓名 + 身份证号 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间 + 购买标准
TInsuranceDetail detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, param.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, param.getEmpIdcardNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, param.getInsuranceCompanyName())
......@@ -3482,8 +3486,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
continue;
}
//商险办理地权限校验
boolean b = insuranceAreaResList.stream().anyMatch(s -> detail.getInsuranceHandleCity().equals(s.getCity()) && detail.getInsuranceHandleProvince().equals(s.getProvince()));
if(!b){
Integer c = detail.getInsuranceHandleCity();
Integer p = detail.getInsuranceHandleProvince();
if(insuranceAreaResList.stream().noneMatch(s -> c.equals(s.getCity()) && p.equals(s.getProvince()))){
param.setErrorMessage(InsurancesConstants.NO_DETAIL_JURISDICTION);
continue;
}
......@@ -3508,49 +3513,44 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
//批增类型,保单号存在
if (detail.getBuyType() == CommonConstants.THREE_INT){
if (StringUtils.isNotBlank(param.getPolicyNo())){
TInsurancePolicy batchPolicyNo = tInsurancePolicyService.getOne(Wrappers.<TInsurancePolicy>query().lambda()
.eq(TInsurancePolicy::getPolicyNo, param.getPolicyNo())
.eq(TInsurancePolicy::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(batchPolicyNo).isPresent()){
param.setErrorMessage(InsurancesConstants.POLICY_NO_NOT_EXIST);
if (detail.getBuyType() == CommonConstants.THREE_INT && StringUtils.isNotBlank(param.getPolicyNo())) {
batchPolicyNo = tInsurancePolicyService.getOne(Wrappers.<TInsurancePolicy>query().lambda()
.eq(TInsurancePolicy::getPolicyNo, param.getPolicyNo())
.eq(TInsurancePolicy::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(batchPolicyNo).isPresent()) {
param.setErrorMessage(InsurancesConstants.POLICY_NO_NOT_EXIST);
continue;
} else {
//保单表中存在保单号,判断保险公司和险种是否一致
if (!batchPolicyNo.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())) {
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
continue;
}
if (!batchPolicyNo.getInsuranceTypeName().equals(param.getInsuranceTypeName())) {
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
continue;
}else {
//保单表中存在保单号,判断保险公司和险种是否一致
if(!batchPolicyNo.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
continue;
}
if(!batchPolicyNo.getInsuranceTypeName().equals(param.getInsuranceTypeName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
continue;
}
}
}
}
//新增类型,保单号已存在但是和填写的保险公司不一致
if (detail.getBuyType() == CommonConstants.ONE_INT){
if (StringUtils.isNotBlank(param.getPolicyNo())){
TInsurancePolicy addPolicyNo = tInsurancePolicyService.getOne(Wrappers.<TInsurancePolicy>query().lambda()
.eq(TInsurancePolicy::getPolicyNo, param.getPolicyNo())
.eq(TInsurancePolicy::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(addPolicyNo).isPresent()){
if (!addPolicyNo.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
continue;
}
if (!addPolicyNo.getInsuranceTypeName().equals(param.getInsuranceTypeName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
continue;
}
}else if (detail.getBuyType() == CommonConstants.ONE_INT && StringUtils.isNotBlank(param.getPolicyNo())) {
//新增类型,保单号已存在但是和填写的保险公司不一致
addPolicyNo = tInsurancePolicyService.getOne(Wrappers.<TInsurancePolicy>query().lambda()
.eq(TInsurancePolicy::getPolicyNo, param.getPolicyNo())
.eq(TInsurancePolicy::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(addPolicyNo).isPresent()) {
if (!addPolicyNo.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())) {
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
continue;
}
if (!addPolicyNo.getInsuranceTypeName().equals(param.getInsuranceTypeName())) {
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
continue;
}
}
}
if (detail.getBuyType() == CommonConstants.FOUR_INT){
......@@ -3580,55 +3580,47 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
//如果当前为合并结算
if (CommonConstants.ZERO_INT == detail.getSettleType() && StringUtils.isNotBlank(detail.getDefaultSettleId())){
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()){
SettleVo settleVo = getInsuranceDetailSettleStatus(detail.getId(), detail.getDefaultSettleId());
settleVo = getInsuranceDetailSettleStatus(detail.getId(), detail.getDefaultSettleId());
if(!Common.isEmpty(settleVo)){
String estimateStatus = settleVo.getEstimateStatus();
String actualStatus = settleVo.getActualStatus();
//保费更新,保单号,发票号不更新
if(booleanActualPremium && !booleanPolicyNo && !booleanInvoiceNo){
if ( InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
if ( InsurancesConstants.SETTLE_TWO.equals(settleVo.getActualStatus())){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(actualStatus)){
if (InsurancesConstants.SETTLE_ONE.equals(settleVo.getActualStatus())){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
continue;
}
}
//
if(!booleanPolicyNo || !booleanInvoiceNo){
if (InsurancesConstants.SETTLE_TWO.equals(estimateStatus) || InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
if (InsurancesConstants.SETTLE_TWO.equals(settleVo.getEstimateStatus()) || InsurancesConstants.SETTLE_TWO.equals(settleVo.getActualStatus())){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(estimateStatus) || InsurancesConstants.SETTLE_ONE.equals(actualStatus)){
if (InsurancesConstants.SETTLE_ONE.equals(settleVo.getEstimateStatus()) || InsurancesConstants.SETTLE_ONE.equals(settleVo.getActualStatus())){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
continue;
}
}
}
}
}
//如果当前为单独结算,判断实缴有没有结算
if (CommonConstants.ONE_INT == detail.getSettleType() && StringUtils.isNotBlank(detail.getDefaultSettleId())){
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
} else if (CommonConstants.ONE_INT == detail.getSettleType() && StringUtils.isNotBlank(detail.getDefaultSettleId())){
//如果当前为单独结算,判断实缴有没有结算
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()){
SettleVo settleVo = getInsuranceDetailSettleStatus(detail.getId(), detail.getDefaultSettleId());
if(!Common.isEmpty(settleVo)){
String actualStatus = settleVo.getActualStatus();
settleVo = getInsuranceDetailSettleStatus(detail.getId(), detail.getDefaultSettleId());
if(!Common.isEmpty(settleVo) && booleanActualPremium && !booleanPolicyNo && !booleanInvoiceNo){
//判断实缴是否结算中
if(booleanActualPremium && !booleanPolicyNo && !booleanInvoiceNo){
if ( InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
continue;
}
if (InsurancesConstants.SETTLE_TWO.equals(settleVo.getActualStatus())) {
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(settleVo.getActualStatus())) {
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
}
}
}
......@@ -3638,6 +3630,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//所有校验通过后设置查到的结果
param.setDetail(detail);
}
map.clear();
return distinctList;
}
......
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