Commit e27ca47f authored by huyuchen's avatar huyuchen

商险优化修改

parent 6222b37d
......@@ -4,9 +4,6 @@ package com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceOperate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author licancan
......@@ -15,6 +12,4 @@ import java.util.List;
*/
@Mapper
public interface TInsuranceOperateMapper extends BaseMapper<TInsuranceOperate> {
int saveOperateInfo(@Param("list") List<TInsuranceOperate> list);
}
......@@ -4,14 +4,10 @@ package com.yifu.cloud.plus.v1.yifu.insurances.service.insurance;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceOperate;
import java.util.List;
/**
* @author licancan
* @description 针对表【t_insurance_operate(商险操作表)】的数据库操作Service
* @date 2022-07-25 14:20:16
*/
public interface TInsuranceOperateService extends IService<TInsuranceOperate> {
int saveOperateInfo(List<TInsuranceOperate> list);
}
......@@ -1736,18 +1736,26 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
List<InsuranceRegisterParam> operatList = registeredPolicyPremiumCheck(paramList,insuranceAreaResList);
//保存到数据库中的结果
List<InsuranceRegisterParam> listSuccess = operatList.stream().filter(e-> e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS)).collect(Collectors.toList());
List<TInsuranceDetail> detailList = new ArrayList<>();
BigDecimal actualMoney;
Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
TSettleDomain settleDomain;
if (CollectionUtils.isNotEmpty(listSuccess)){
//商险明细更新list
List<TInsuranceDetail> detailList = new ArrayList<>();
//项目信息
Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
//保单号list
List<TInsurancePolicy> policyList = new ArrayList<>();
//业务操作记录表list
List<TBusinessOperate> operateList = new ArrayList<>();
//结算信息list
List<TInsuranceSettle> settleList = new ArrayList<>();
BigDecimal actualMoney;
TSettleDomain settleDomain;
TInsuranceDetail detail;
List<TInsuranceReplace> list;
List<TInsuranceReplace> replaceList;
TInsuranceSettle settle;
TInsurancePolicy one;
BigDecimal bigDecimalAct;
for (InsuranceRegisterParam success : listSuccess) {
long d1 = System.currentTimeMillis();
//登记保单保费
......@@ -1782,13 +1790,25 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (StringUtils.isNotBlank(success.getPolicyNo())){
detail.setPolicyNo(success.getPolicyNo());
//保单号不为空,维护到保单表中
TInsurancePolicy policy = new TInsurancePolicy();
policy.setPolicyNo(success.getPolicyNo());
policy.setPolicyStart(detail.getPolicyStart());
policy.setPolicyEnd(detail.getPolicyEnd());
policy.setInsuranceCompanyName(detail.getInsuranceCompanyName());
policy.setInsuranceTypeName(detail.getInsuranceTypeName());
tInsurancePolicyService.saveTInsurancePolicy(policy);
one = tInsurancePolicyService.getOne(Wrappers.<TInsurancePolicy>query().lambda()
.eq(TInsurancePolicy::getPolicyNo, success.getPolicyNo())
.eq(TInsurancePolicy::getDeleteFlag,CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
if (!Optional.ofNullable(one).isPresent()){
TInsurancePolicy policy = new TInsurancePolicy();
policy.setPolicyNo(success.getPolicyNo());
policy.setPolicyStart(detail.getPolicyStart());
policy.setPolicyEnd(detail.getPolicyEnd());
policy.setInsuranceCompanyName(detail.getInsuranceCompanyName());
policy.setInsuranceTypeName(detail.getInsuranceTypeName());
policyList.add(policy);
//第一次新增插入变更记录表为insert,前端会将insert渲染为批量导入
TBusinessOperate operate = new TBusinessOperate();
operate.setBusinessId(policy.getId());
operate.setDifferenceInfo("insert");
operateList.add(operate);
}
//如果保单号不为空,将替换类型的保单号也全部更新
replaceList = tInsuranceReplaceService.list(Wrappers.<TInsuranceReplace>query().lambda()
......@@ -1805,20 +1825,19 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
//如果保费不为空
if (StringUtils.isNotBlank(success.getActualPremium())){
BigDecimal bigDecimalAct = new BigDecimal(success.getActualPremium());
bigDecimalAct = new BigDecimal(success.getActualPremium());
//如果当前保单为合并结算
if (detail.getSettleType() == CommonConstants.ZERO_INT &&
StringUtils.isNotBlank(detail.getDefaultSettleId())) {
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()) {
Integer isActualPush = settle.getIsActualPush();
//如果当前实缴信息未推送,则新增实缴单推送
if (CommonConstants.ZERO_INT == isActualPush) {
if (CommonConstants.ZERO_INT == settle.getIsActualPush()) {
//保费存储
settle.setActualPremium(bigDecimalAct);
settle.setIsActualPush(CommonConstants.ZERO_INT);
settle.setUpdateTime(LocalDateTime.now());
tInsuranceSettleService.updateById(settle);
settleList.add(settle);
//调EKP新增实际保费
detail.setActualPremium(bigDecimalAct);
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.TWO_INT);
......@@ -1829,7 +1848,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
settle.setActualPremium(bigDecimalAct);
settle.setIsActualPush(CommonConstants.ZERO_INT);
settle.setUpdateTime(LocalDateTime.now());
tInsuranceSettleService.updateById(settle);
settleList.add(settle);
//调EKP更新实际保费
detail.setActualPremium(bigDecimalAct);
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.FOUR_INT);
......@@ -1838,34 +1857,34 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//如果当前保单为单独结算
} else if(detail.getSettleType() == CommonConstants.ONE_INT){
//推送过实缴信息且金额与本次不一致,则推送更新
boolean c = !Common.isNotNull(detail.getActualPremium()) ||
bigDecimalAct.compareTo(detail.getActualPremium()) != 0;
if(StringUtils.isNotBlank(detail.getDefaultSettleId()) && c){
if(StringUtils.isNotBlank(detail.getDefaultSettleId()) &&
(!Common.isNotNull(detail.getActualPremium()) ||
bigDecimalAct.compareTo(detail.getActualPremium()) != 0)){
//推送保费更新
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle.setActualPremium(bigDecimalAct);
settle.setIsActualPush(CommonConstants.ZERO_INT);
settle.setUpdateTime(LocalDateTime.now());
tInsuranceSettleService.updateById(settle);
settleList.add(settle);
//调EKP更新实际保费
detail.setActualPremium(bigDecimalAct);
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.FOUR_INT);
//未推送过实缴信息,则推送新增
} else if(StringUtils.isBlank(detail.getDefaultSettleId())){
//保费存储
settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setActualPremium(bigDecimalAct);
settle.setIsActualPush(CommonConstants.ZERO_INT);
TInsuranceSettle settleNew = new TInsuranceSettle();
settleNew.setInsDetailId(detail.getId());
settleNew.setSettleType(detail.getSettleType());
settleNew.setSettleHandleStatus(CommonConstants.ONE_STRING);
settleNew.setActualPremium(bigDecimalAct);
settleNew.setIsActualPush(CommonConstants.ZERO_INT);
//调完ekp接口才会是1
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
settleNew.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settleNew);
detail.setDefaultSettleId(settleNew.getId());
//调EKP新增实际保费
detail.setActualPremium(bigDecimalAct);
doJointInsuranceTask.asynchronousEkpInfo(detail,settle,CommonConstants.TWO_INT);
doJointInsuranceTask.asynchronousEkpInfo(detail,settleNew,CommonConstants.TWO_INT);
}
}
}
......@@ -1979,15 +1998,28 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
long d2 = System.currentTimeMillis();
log.info("登记保单保费一条耗时:" + (d2 - d1));
}
}
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;
mapSelectVo.clear();
//批量更新和插入数据
if (!detailList.isEmpty()) {
this.updateBatchById(detailList);
}
if (!settleList.isEmpty()) {
tInsuranceSettleService.updateBatchById(settleList);
settleList.clear();
}
if (!policyList.isEmpty()) {
tInsurancePolicyService.saveBatch(policyList);
policyList.clear();
}
if (!operateList.isEmpty()) {
tBusinessOperateService.saveBatch(operateList);
operateList.clear();
}
//操作记录
addOperate(detailList,user,InsurancesConstants.REGISTERED,null,CommonConstants.ONE_INT);
if (operatList.stream().allMatch(e->e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS))) {
operatList = null;
}
}
return R.ok(operatList,InsurancesConstants.OPERATE_SUCCESS);
}
......@@ -3449,11 +3481,17 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间、购买标准
StringBuilder errorTemp = new StringBuilder();
errorTemp.append(param.getEmpName());
errorTemp.append("_");
errorTemp.append(param.getEmpIdcardNo());
errorTemp.append("_");
errorTemp.append(param.getInsuranceCompanyName());
errorTemp.append("_");
errorTemp.append(param.getInsuranceTypeName());
errorTemp.append("_");
errorTemp.append(param.getPolicyStart());
errorTemp.append("_");
errorTemp.append(param.getPolicyEnd());
errorTemp.append("_");
errorTemp.append(param.getBuyStandard());
if (null == map.get(errorTemp.toString())) {
map.put(errorTemp.toString(),"1");
......@@ -3501,7 +3539,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
continue;
}
// 如果保费不存在,保单号、保费必填
if (detail.getActualPremium() == null){
if (null == detail.getActualPremium()){
if (StringUtils.isBlank(param.getPolicyNo())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_EMPTY);
continue;
......@@ -3595,7 +3633,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
continue;
}
}
//
//保单号,发票号更新时
if(!booleanPolicyNo || !booleanInvoiceNo){
if (InsurancesConstants.SETTLE_TWO.equals(settleVo.getEstimateStatus()) || InsurancesConstants.SETTLE_TWO.equals(settleVo.getActualStatus())){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
......@@ -3894,7 +3932,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
List<TInsuranceOperate> operateList = new ArrayList<>();
for (TInsuranceDetail detail : detailList) {
TInsuranceOperate operate = new TInsuranceOperate();
operate.setId(String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
operate.setRemark(remark);
operate.setDisplayFlag(displayFlag);
operate.setInsuranceDetailId(detail.getId());
......@@ -3904,7 +3941,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
operate.setCreateTime(LocalDateTime.now());
operateList.add(operate);
}
tInsuranceOperateService.saveOperateInfo(operateList);
tInsuranceOperateService.saveBatch(operateList);
}
}
......
......@@ -6,8 +6,6 @@ import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TInsuranceOperat
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsuranceOperateService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author licancan
......@@ -16,9 +14,4 @@ import java.util.List;
*/
@Service
public class TInsuranceOperateServiceImpl extends ServiceImpl<TInsuranceOperateMapper, TInsuranceOperate> implements TInsuranceOperateService {
@Override
public int saveOperateInfo(List<TInsuranceOperate> list) {
return baseMapper.saveOperateInfo(list);
}
}
......@@ -19,22 +19,4 @@
ID,INSURANCE_DETAIL_ID,OPERATE_DESC,REMARK,
CREATE_BY,CREATE_NAME,CREATE_TIME
</sql>
<insert id="saveOperateInfo" parameterType="java.util.List">
insert into t_insurance_operate
(ID,REMARK,DISPLAY_FLAG,CREATE_BY,CREATE_TIME,CREATE_NAME,OPERATE_DESC,INSURANCE_DETAIL_ID)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id},
#{item.remark},
#{item.displayFlag},
#{item.createBy},
#{item.createTime},
#{item.createName},
#{item.operateDesc},
#{item.insuranceDetailId}
)
</foreach>
</insert>
</mapper>
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