Commit 523ffe01 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/MVP1.5.1' into MVP1.5.1

parents 724c1d6e 9b58c4ca
......@@ -17,6 +17,7 @@ import com.yifu.cloud.plus.v1.yifu.social.vo.ChangeDeptVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......
......@@ -42,6 +42,7 @@ import com.yifu.cloud.plus.v1.yifu.social.vo.TIncomeDetailReturnVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
......@@ -1157,6 +1158,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
// 被替换的id
List<String> replaceIdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(detailList)){
TInsuranceReplace one;
TInsuranceDetail byId;
for (TInsuranceDetail detail : detailList) {
if (detail.getBuyHandleStatus() == CommonConstants.FOUR_INT
|| detail.getBuyHandleStatus() == CommonConstants.FIVE_INT){
......@@ -1178,14 +1181,14 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if(detail.getBuyType() == CommonConstants.FOUR_INT){
//替换者有效状态为空
detail.setIsEffect(null);
TInsuranceReplace one = tInsuranceReplaceService.getOne(Wrappers.<TInsuranceReplace>query().lambda()
one = tInsuranceReplaceService.getOne(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getToInsuranceDetailId, detail.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Optional.ofNullable(one).isPresent()){
//替换记录变为失败
one.setReplaceStatus(CommonConstants.ZERO_INT);
tInsuranceReplaceService.updateById(one);
TInsuranceDetail byId = this.getById(one.getFromInsuranceDetailId());
byId = this.getById(one.getFromInsuranceDetailId());
if (Optional.ofNullable(byId).isPresent()){
//被替换者激活
byId.setIsEffect(CommonConstants.ZERO_INT);
......@@ -1214,9 +1217,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
}
if (CollectionUtils.isNotEmpty(successList)){
TInsuranceSettle settle;
SettleVo settleVo;
for (TInsuranceDetail detail : successList) {
if (StringUtils.isNotBlank(detail.getDefaultSettleId())){
TInsuranceSettle settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()){
TInsuranceSettle burden = new TInsuranceSettle();
BeanCopyUtils.copyProperties(settle,burden);
......@@ -1234,7 +1239,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setEstimatePremium(new BigDecimal("0.00"));
}
tInsuranceSettleService.save(burden);
SettleVo settleVo = getInsuranceDetailSettleStatus(detail.getId(), detail.getDefaultSettleId());
settleVo = getInsuranceDetailSettleStatus(detail.getId(), detail.getDefaultSettleId());
if(!Common.isEmpty(settleVo) ){
//预估推送标识
Integer isEstimatePush = settle.getIsEstimatePush();
......@@ -1255,9 +1260,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setDefaultSettleId(burden.getId());
pushResult = pushEstimate(detail, CommonConstants.THREE_INT);
}
}
//预估已推送,实缴已推送
if(isEstimatePush == CommonConstants.ONE_INT && isActualPush == CommonConstants.ONE_INT){
//预估已推送,实缴已推送
} else if(isEstimatePush == CommonConstants.ONE_INT && isActualPush == CommonConstants.ONE_INT){
//预估未结算,实缴未结算推送作废
if(InsurancesConstants.SETTLE_ZERO.equals(estimateStatus) && InsurancesConstants.SETTLE_ZERO.equals(actualStatus)){
pushResult= pushEstimate(detail, CommonConstants.FIVE_INT);
......@@ -1266,9 +1270,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setDefaultSettleId(burden.getId());
pushResult= pushEstimate(detail, CommonConstants.SIX_INT);
}
}
//预估未推送,实缴已推送
if(isEstimatePush == CommonConstants.ZERO_INT && isActualPush == CommonConstants.ONE_INT){
//预估未推送,实缴已推送
} else if(isEstimatePush == CommonConstants.ZERO_INT && isActualPush == CommonConstants.ONE_INT){
//实缴未结算推送作废
if(InsurancesConstants.SETTLE_ZERO.equals(actualStatus)){
pushResult= pushEstimate(detail, CommonConstants.FIVE_INT);
......@@ -1299,7 +1302,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
});
}
//更新状态
this.saveOrUpdateBatch(successList);
this.updateBatchById(successList);
// 处理档案状态
if (CollectionUtils.isNotEmpty(successList)) {
......@@ -1374,7 +1377,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
@Override
@Transactional(value = "insurancesTransactionManager" ,rollbackFor = {Exception.class})
public R<List<InsuranceListVO>> successfulInsurance(YifuUser user, List<InsuranceHandleParam> paramList) {
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(50, 50, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(10));
//解析参数里的商险id
List<String> idList = paramList.stream().map(InsuranceHandleParam::getId).distinct().collect(Collectors.toList());
//操作日志对象
......@@ -1385,14 +1387,21 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
List<InsuranceListVO> errorList = new ArrayList<>();
//后端处理的数据
List<TInsuranceDetail> successList = new ArrayList<>();
List<TInsuranceDetail> successOne = new ArrayList<>();
List<TInsuranceDetail> successTwo = new ArrayList<>();
//被替换人标记被替换成功
List<TInsuranceDetail> sourceList = new ArrayList<>();
//被替换人的档案要处理状态
List<String> sourceIdCardList = new ArrayList<>();
// 被替换的id
List<String> replaceIdList = new ArrayList<>();
List<TInsuranceSettle> settleList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(detailList)){
TInsuranceReplace one;
//项目信息
Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
TSettleDomain settleDomain;
TInsuranceDetail byId;
for (TInsuranceDetail detail : detailList) {
//先判断投保状态是不是投保中,如果不是不给标记办理成功,防止重复推数据
if(detail.getBuyHandleStatus() != CommonConstants.TWO_INT){
......@@ -1415,14 +1424,14 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setUpdateBy(user.getId());
//替换类型,保单生效日期:T + 1
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
successList.add(detail);
successOne.add(detail);
//查找被替换人信息
one = tInsuranceReplaceService.getOne(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getToInsuranceDetailId, detail.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Optional.ofNullable(one).isPresent()) {
TInsuranceDetail byId = this.getById(one.getFromInsuranceDetailId());
byId = this.getById(one.getFromInsuranceDetailId());
if (Optional.ofNullable(byId).isPresent()) {
sourceList.add(byId);
replaceIdList.add(byId.getId());
......@@ -1430,6 +1439,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
}
}else{
//获取项目信息
if (null != mapSelectVo) {
settleDomain = mapSelectVo.get(detail.getDeptNo());
} else {
settleDomain = null;
}
//根据结算类型判断是否需要计算预估保费
//预估
if (detail.getSettleType() == CommonConstants.ZERO_INT){
......@@ -1449,21 +1464,24 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
detail.setUpdateTime(LocalDateTime.now());
detail.setUpdateBy(user.getId());
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setCreateTime(LocalDateTime.now());
settle.setEstimatePushTime(LocalDateTime.now());
settle.setEstimatePremium(estimatePremium);
//调完ekp接口才会是1
settle.setIsEstimatePush(CommonConstants.ZERO_INT);
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
String settleId = RandomStringUtils.randomNumeric(19);
settle.setId(settleId);
settleList.add(settle);
detail.setDefaultSettleId(settleId);
successTwo.add(detail);
//生成收入数据
createInsuranceInfo(detail,null);
createInsuranceInfo(detail,settleDomain);
}else {
//按天
//计算起止时间的天数
......@@ -1483,7 +1501,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
detail.setUpdateTime(LocalDateTime.now());
detail.setUpdateBy(user.getId());
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
......@@ -1494,11 +1512,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
settle.setIsEstimatePush(CommonConstants.ONE_INT);
settle.setEstimatePushTime(LocalDateTime.now());
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
String settleId = RandomStringUtils.randomNumeric(19);
settle.setId(settleId);
settleList.add(settle);
detail.setDefaultSettleId(settleId);
successTwo.add(detail);
//生成收入数据
createInsuranceInfo(detail,null);
createInsuranceInfo(detail,settleDomain);
}
}
//实缴
......@@ -1514,40 +1534,35 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
detail.setUpdateTime(LocalDateTime.now());
successList.add(detail);
detail.setUpdateBy(user.getId());
successOne.add(detail);
}
}
}
}
}
updateBatchById(successList);
//分开操作保证批量更新
updateBatchById(successOne);
updateBatchById(successTwo);
successList.addAll(successOne);
successList.addAll(successTwo);
successOne.clear();
successTwo.clear();
//插入结算数据
if (!settleList.isEmpty()) {
tInsuranceSettleService.saveBatch(settleList);
settleList.clear();
}
// 被替换的老商险,要处理档案状态
if (CollectionUtils.isNotEmpty(sourceIdCardList)) {
this.doFailInfo(sourceList, sourceIdCardList, replaceIdList, CommonConstants.THREE_STRING);
}
if (CollectionUtils.isNotEmpty(successList)) {
// 同步操作档案的 商险状态为:2正常(0无2正常3失效4处理中)
this.updateEmpInfp(successList, CommonConstants.TWO_STRING);
// 异步任务操作档案的 商险状态为:2正常(0无2正常3失效4处理中)
doJointInsuranceTask.updateEmpInfp(successList, CommonConstants.TWO_STRING);
threadPool.execute(() -> {
//根据结算类型是合并结算,推送预估保费到ekp(上面已经算好,这里直接判断有预估保费的就推送)
for (TInsuranceDetail tInsuranceDetail : successList) {
Integer settleType = tInsuranceDetail.getSettleType();
//如果是合并计算则推送至EKP
if(CommonConstants.ZERO_INT == settleType){
//存储成功后发送给EKP
String s = pushEstimate(tInsuranceDetail,CommonConstants.ONE_INT);
if(StringUtils.isNotBlank(s)){
LambdaUpdateWrapper<TInsuranceSettle> settleWrapper = new LambdaUpdateWrapper<>();
settleWrapper.eq(TInsuranceSettle :: getId,tInsuranceDetail.getDefaultSettleId())
.set(TInsuranceSettle :: getIsEstimatePush,CommonConstants.ONE_INT)
.set(TInsuranceSettle :: getEstimatePushTime,LocalDateTime.now());
//更新结算信息表
tInsuranceSettleService.update(settleWrapper);
}
}
}
});
//异步任务推送
doJointInsuranceTask.pushEstime(successList);
}
//操作记录
if (CollectionUtils.isNotEmpty(successList)){
......@@ -1629,8 +1644,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
archivesDaprUtil.updateEmployeeInfoInsuranceStatus(empStatusVo);
}
} else {
// 同步操作档案的 商险状态为:3失效(0无2正常3失效4处理中)
this.updateEmpInfp(sourceList, toStatus);
// 异步任务操作档案的 商险状态为:3失效(0无2正常3失效4处理中)
doJointInsuranceTask.updateEmpInfp(sourceList, toStatus);
}
}
......@@ -1802,6 +1817,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
policy.setPolicyEnd(detail.getPolicyEnd());
policy.setInsuranceCompanyName(detail.getInsuranceCompanyName());
policy.setInsuranceTypeName(detail.getInsuranceTypeName());
policy.setId(RandomStringUtils.randomNumeric(19));
policyList.add(policy);
//第一次新增插入变更记录表为insert,前端会将insert渲染为批量导入
......@@ -1999,7 +2015,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
long d2 = System.currentTimeMillis();
log.info("登记保单保费一条耗时:" + (d2 - d1));
}
mapSelectVo.clear();
//批量更新和插入数据
if (!detailList.isEmpty()) {
this.updateBatchById(detailList);
......
package com.yifu.cloud.plus.v1.yifu.insurances.util;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpIdCardAndDeptVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpStatusVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.SalaryDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.SocialDaprUtils;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
......@@ -30,6 +34,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -69,7 +74,11 @@ public class DoJointInsuranceTask {
@Autowired
private TUpdateStatusErrorMapper updateStatusErrorMapper;
/**
@Autowired
private ArchivesDaprUtil archivesDaprUtil;
/**
* @Description: 商险明细推送
* @Author: huyc
* @Date: 2022-11-30
......@@ -96,6 +105,22 @@ public class DoJointInsuranceTask {
log.info("推送商险明细到EKP结束");
}
/**
* 保存失败信息
*
* @author zhaji
* @param
* @return {@link String}
*/
private void saveInsuranceEkp(EkpInteractiveParam param, Integer pushType){
TInsuranceEkp ekp = new TInsuranceEkp();
BeanCopyUtils.copyProperties(param,ekp);
ekp.setId(null);
ekp.setCreateTime(LocalDateTime.now());
ekp.setPushType(pushType);
tInsuranceEkpService.save(ekp);
}
/**
* 推送EKP
*
......@@ -188,22 +213,6 @@ public class DoJointInsuranceTask {
}
}
/**
* 保存失败信息
*
* @author zhaji
* @param
* @return {@link String}
*/
private void saveInsuranceEkp(EkpInteractiveParam param, Integer pushType){
TInsuranceEkp ekp = new TInsuranceEkp();
BeanCopyUtils.copyProperties(param,ekp);
ekp.setId(null);
ekp.setCreateTime(LocalDateTime.now());
ekp.setPushType(pushType);
tInsuranceEkpService.save(ekp);
}
@Async
public void updateInsuranceSettleStatus(EkpStatusParamVo vo) {
try {
......@@ -470,4 +479,54 @@ public class DoJointInsuranceTask {
log.error("薪资结算状态更新异常", e);
}
}
/**
* @param sourceList
* @Description: // 同步操作档案的 商险状态为:3失效(0无2正常3失效4处理中)
* @Author: hgw
* @Date: 2022/11/23 15:46
* @return: void
**/
@Async
public void updateEmpInfp(List<TInsuranceDetail> sourceList, String status) {
EmpStatusVo empStatusVo = new EmpStatusVo();
EmpIdCardAndDeptVo empIdCardAndDeptVo;
List<EmpIdCardAndDeptVo> voList = new ArrayList<>();
for (TInsuranceDetail d : sourceList) {
empIdCardAndDeptVo = new EmpIdCardAndDeptVo();
empIdCardAndDeptVo.setIdCard(d.getEmpIdcardNo());
empIdCardAndDeptVo.setDeptNo(d.getDeptNo());
empIdCardAndDeptVo.setStatus(status);
voList.add(empIdCardAndDeptVo);
}
empStatusVo.setEmpInfo(voList);
archivesDaprUtil.updateEmployeeInsuranceStatus(empStatusVo);
archivesDaprUtil.updateEmployeeInfoInsuranceStatus(empStatusVo);
}
/**
* @Description: 商险明细推送
* @Author: huyc
* @Date: 2022-11-30
* @return: void
**/
@Async
public void pushEstime(List<TInsuranceDetail> successList) {
//根据结算类型是合并结算,推送预估保费到ekp(上面已经算好,这里直接判断有预估保费的就推送)
for (TInsuranceDetail tInsuranceDetail : successList) {
//如果是合并计算则推送至EKP
if (CommonConstants.ZERO_INT == tInsuranceDetail.getSettleType()) {
//存储成功后发送给EKP
String s = pushEstimate(tInsuranceDetail, CommonConstants.ONE_INT);
if (StringUtils.isNotBlank(s)) {
LambdaUpdateWrapper<TInsuranceSettle> settleWrapper = new LambdaUpdateWrapper<>();
settleWrapper.eq(TInsuranceSettle::getId, tInsuranceDetail.getDefaultSettleId())
.set(TInsuranceSettle::getIsEstimatePush, CommonConstants.ONE_INT)
.set(TInsuranceSettle::getEstimatePushTime, LocalDateTime.now());
//更新结算信息表
tInsuranceSettleService.update(settleWrapper);
}
}
}
}
}
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