Commit 41cea215 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/develop' into develop

parents fe73d4f2 a57c7c8a
...@@ -120,6 +120,10 @@ public class InsurancesConstants { ...@@ -120,6 +120,10 @@ public class InsurancesConstants {
* 当前记录在减员流程中,无法替换 * 当前记录在减员流程中,无法替换
*/ */
public static final String REDUCE_REPLACE_IS_NOT_ALLOW = "当前记录在减员流程中,无法替换"; public static final String REDUCE_REPLACE_IS_NOT_ALLOW = "当前记录在减员流程中,无法替换";
/**
* 已减员,无法退回
*/
public static final String REDUCE_ROLLBACK_IS_NOT_ALLOW = "已减员,无法退回";
/** /**
* 员工姓名不能为空 * 员工姓名不能为空
*/ */
...@@ -184,6 +188,10 @@ public class InsurancesConstants { ...@@ -184,6 +188,10 @@ public class InsurancesConstants {
* 险种不存在 * 险种不存在
*/ */
public static final String INSURANCE_TYPE_NAME_NOT_EXIST = "险种不存在"; public static final String INSURANCE_TYPE_NAME_NOT_EXIST = "险种不存在";
/**
* 费率不存在
*/
public static final String INSURANCE_TYPE_RATE_NOT_EXIST = "费率不存在";
/** /**
* 保单开始时间不能为空 * 保单开始时间不能为空
*/ */
......
...@@ -213,7 +213,7 @@ public class TInsuranceDetail extends BaseEntity { ...@@ -213,7 +213,7 @@ public class TInsuranceDetail extends BaseEntity {
* 默认结算信息id * 默认结算信息id
*/ */
@Schema(description = "默认结算信息id") @Schema(description = "默认结算信息id")
private Integer defaultSettleId; private String defaultSettleId;
/** /**
* 减员状态 1待减员 2减员中3减员退回 * 减员状态 1待减员 2减员中3减员退回
......
...@@ -35,7 +35,7 @@ public class TInsuranceSettle implements Serializable { ...@@ -35,7 +35,7 @@ public class TInsuranceSettle implements Serializable {
/** /**
* 结算状态 * 结算状态
*/ */
@Schema(description = "结算状态") @Schema(description = "结算状态 1、待结算,2、结算中,3、已结算")
private String settleHandleStatus; private String settleHandleStatus;
/** /**
......
package com.yifu.cloud.plus.v1.yifu.insurances.util; package com.yifu.cloud.plus.v1.yifu.insurances.util;
import cn.hutool.core.date.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import java.text.DateFormat; import java.text.DateFormat;
...@@ -185,7 +186,86 @@ public class LocalDateUtil { ...@@ -185,7 +186,86 @@ public class LocalDateUtil {
return flag; return flag;
} }
/**
* 计算相差多少天,如果开始时间晚于结束时间会对调
*
* @author licancan
* @param startDate
* @param endDate
* @return {@link long}
*/
public static long betweenDay(String startDate,String endDate){
long dif = 0;
//在日期字符串非空时执行
if (!Common.isEmpty(startDate) && !Common.isEmpty(endDate)) {
Date parseStartDate = null;
Date parseEndDate = null;
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat(NORM_DATE_PATTERN, Locale.CHINA);
try {
//将字符串转为日期格式,如果此处字符串为非合法日期就会抛出异常。
parseStartDate = sdf.parse(startDate);
parseEndDate = sdf.parse(endDate);
//调用hutool里面的DateUtil.betweenDay方法来做判断
dif = DateUtil.betweenDay(parseStartDate, parseEndDate, true);
} catch (ParseException e) {
e.printStackTrace();
}
}else {
System.out.println("日期参数不可为空");
}
return dif + 1;
}
/**
* 计算相差月份,如果开始时间晚于结束时间会对调
* 公式:(endYear - starYear) * 12 + endMonth - startMonth + (endDay >= startDay ? 1 : 0)
* @author licancan
* @param startDate
* @param endDate
* @return {@link long}
*/
public static long betweenMonth(String startDate,String endDate){
long dif = 0;
//在日期字符串非空时执行
if (!Common.isEmpty(startDate) && !Common.isEmpty(endDate)) {
Date parseStartDate = null;
Date parseEndDate = null;
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat(NORM_DATE_PATTERN, Locale.CHINA);
try {
//将字符串转为日期格式,如果此处字符串为非合法日期就会抛出异常。
parseStartDate = sdf.parse(startDate);
parseEndDate = sdf.parse(endDate);
//如果开始时间晚于结束时间对调
if (parseStartDate.after(parseEndDate)) {
Date t = parseStartDate;
parseStartDate = parseEndDate;
parseEndDate = t;
}
Calendar starCalendar = Calendar.getInstance();
starCalendar.setTime(parseStartDate);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(parseEndDate);
int starYear = starCalendar.get(Calendar.YEAR);
int startMonth = starCalendar.get(Calendar.MONTH);
int startDay = starCalendar.get(Calendar.DATE);
int endYear = endCalendar.get(Calendar.YEAR);
int endMonth = endCalendar.get(Calendar.MONTH);
int endDay = endCalendar.get(Calendar.DATE);
dif = (endYear - starYear) * 12 + endMonth - startMonth + (endDay >= startDay ? 1 : 0);
} catch (ParseException e) {
e.printStackTrace();
}
}else {
System.out.println("日期参数不可为空");
}
return dif;
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(compareDate("2022-07-26","2022-07-27")); System.out.println(betweenMonth("2022-10-03","2022-08-03"));
} }
} }
...@@ -52,6 +52,18 @@ public class InsuranceExportListVO implements Serializable { ...@@ -52,6 +52,18 @@ public class InsuranceExportListVO implements Serializable {
@Schema(description = " 投保类型, 1新增、3批增、4替换") @Schema(description = " 投保类型, 1新增、3批增、4替换")
private Integer buyType; private Integer buyType;
/**
* 购买月数
*/
@Schema(description = "购买月数")
private Long buyMonth;
/**
* 购买天数
*/
@Schema(description = "购买天数")
private Long buyDay;
/** /**
* 投保岗位 * 投保岗位
*/ */
......
...@@ -42,6 +42,12 @@ public class InsuranceListVO implements Serializable { ...@@ -42,6 +42,12 @@ public class InsuranceListVO implements Serializable {
@Schema(description = " 投保类型, 1新增、3批增、4替换") @Schema(description = " 投保类型, 1新增、3批增、4替换")
private Integer buyType; private Integer buyType;
/**
* 购买月数
*/
@Schema(description = "购买月数")
private Long buyMonth;
/** /**
* 项目名称 * 项目名称
*/ */
...@@ -115,4 +121,10 @@ public class InsuranceListVO implements Serializable { ...@@ -115,4 +121,10 @@ public class InsuranceListVO implements Serializable {
*/ */
@Schema(description = "结算月") @Schema(description = "结算月")
private String settleMonth; private String settleMonth;
/**
* 错误信息
*/
@Schema(description = "错误信息")
private String errorMessage;
} }
...@@ -160,11 +160,11 @@ public class TInsuranceDetailController { ...@@ -160,11 +160,11 @@ public class TInsuranceDetailController {
* *
* @author licancan * @author licancan
* @param idList * @param idList
* @return {@link R<List<TInsuranceDetail>>} * @return {@link R<List<InsuranceListVO>>}
*/ */
@Operation(summary = "投保退回", description = "投保退回") @Operation(summary = "投保退回", description = "投保退回")
@PostMapping("/rollBackInsurance") @PostMapping("/rollBackInsurance")
public R<List<TInsuranceDetail>> rollBackInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<String> idList){ public R<List<InsuranceListVO>> rollBackInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<String> idList){
return tInsuranceDetailService.rollBackInsurance(idList); return tInsuranceDetailService.rollBackInsurance(idList);
} }
...@@ -173,11 +173,11 @@ public class TInsuranceDetailController { ...@@ -173,11 +173,11 @@ public class TInsuranceDetailController {
* *
* @author licancan * @author licancan
* @param idList * @param idList
* @return {@link R<List<TInsuranceDetail>>} * @return {@link R<List<InsuranceListVO>>}
*/ */
@Operation(summary = "办理成功", description = "办理成功") @Operation(summary = "办理成功", description = "办理成功")
@PostMapping("/successfulInsurance") @PostMapping("/successfulInsurance")
public R<List<TInsuranceDetail>> successfulInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<String> idList){ public R<List<InsuranceListVO>> successfulInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<String> idList){
return tInsuranceDetailService.successfulInsurance(idList); return tInsuranceDetailService.successfulInsurance(idList);
} }
......
...@@ -104,18 +104,18 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> { ...@@ -104,18 +104,18 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
* *
* @author licancan * @author licancan
* @param idList * @param idList
* @return {@link R<List<TInsuranceDetail>>} * @return {@link R<List<InsuranceListVO>>}
*/ */
R<List<TInsuranceDetail>> rollBackInsurance(List<String> idList); R<List<InsuranceListVO>> rollBackInsurance(List<String> idList);
/** /**
* 办理成功 * 办理成功
* *
* @author licancan * @author licancan
* @param idList * @param idList
* @return {@link R<List<TInsuranceDetail>>} * @return {@link R<List<InsuranceListVO>>}
*/ */
R<List<TInsuranceDetail>> successfulInsurance(List<String> idList); R<List<InsuranceListVO>> successfulInsurance(List<String> idList);
/** /**
* 登记保单保费 * 登记保单保费
......
...@@ -62,6 +62,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -62,6 +62,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
@Lazy @Lazy
private TInsuranceTypeStandardService tInsuranceTypeStandardService; private TInsuranceTypeStandardService tInsuranceTypeStandardService;
@Resource @Resource
@Lazy
private TInsuranceTypeRateService tInsuranceTypeRateService;
@Resource
private TInsuranceReplaceService tInsuranceReplaceService; private TInsuranceReplaceService tInsuranceReplaceService;
@Resource @Resource
private ArchivesDaprUtil archivesDaprUtil; private ArchivesDaprUtil archivesDaprUtil;
...@@ -88,19 +91,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -88,19 +91,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
public IPage<InsuranceListVO> getInsuranceListPage(Page<InsuranceListVO> page, InsuranceListParam param) { public IPage<InsuranceListVO> getInsuranceListPage(Page<InsuranceListVO> page, InsuranceListParam param) {
//todo 根据登录人获取数据权限 //todo 根据登录人获取数据权限
IPage<InsuranceListVO> insuranceList = baseMapper.getInsuranceListPage(page,param); IPage<InsuranceListVO> insuranceList = baseMapper.getInsuranceListPage(page,param);
if (CollectionUtils.isNotEmpty(insuranceList.getRecords())){
//根据项目编码获取项目名称 //根据项目编码获取项目名称
List<String> collect = insuranceList.getRecords().stream().map(e -> e.getDeptNo()).distinct().collect(Collectors.toList()); setProjectNameByDeptNo(insuranceList.getRecords());
R<SetInfoVo> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(collect); // 购买月数
if (null != setInfoByCodes && setInfoByCodes.getCode() == CommonConstants.SUCCESS && Common.isNotNull(setInfoByCodes.getData())) { if (CollectionUtils.isNotEmpty(insuranceList.getRecords())){
Map<String, ProjectSetInfoVo> data = setInfoByCodes.getData().getProjectSetInfoVoMap(); insuranceList.getRecords().stream().forEach(e ->{
for (InsuranceListVO record : insuranceList.getRecords()) { e.setBuyMonth(LocalDateUtil.betweenMonth(e.getPolicyStart().toString(),e.getPolicyEnd().toString()));
ProjectSetInfoVo jsonObject = data.get(record.getDeptNo()); });
if (null != jsonObject){
record.setProjectName(Optional.ofNullable(jsonObject.getDepartName()).orElse(""));
}
}
}
} }
return insuranceList; return insuranceList;
} }
...@@ -116,19 +113,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -116,19 +113,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
public List<InsuranceListVO> getInsuranceList(InsuranceListParam param) { public List<InsuranceListVO> getInsuranceList(InsuranceListParam param) {
//todo 根据登录人获取数据权限 //todo 根据登录人获取数据权限
List<InsuranceListVO> insuranceList = baseMapper.getInsuranceList(param); List<InsuranceListVO> insuranceList = baseMapper.getInsuranceList(param);
if (CollectionUtils.isNotEmpty(insuranceList)){
//根据项目编码获取项目名称 //根据项目编码获取项目名称
List<String> collect = insuranceList.stream().map(e -> e.getDeptNo()).distinct().collect(Collectors.toList()); setProjectNameByDeptNo(insuranceList);
R<SetInfoVo> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(collect); // 购买月数
if (null != setInfoByCodes && setInfoByCodes.getCode() == CommonConstants.SUCCESS && Common.isNotNull(setInfoByCodes.getData())) { if (CollectionUtils.isNotEmpty(insuranceList)){
Map<String, ProjectSetInfoVo> data = setInfoByCodes.getData().getProjectSetInfoVoMap(); insuranceList.stream().forEach(e ->{
for (InsuranceListVO record : insuranceList) { e.setBuyMonth(LocalDateUtil.betweenMonth(e.getPolicyStart().toString(),e.getPolicyEnd().toString()));
ProjectSetInfoVo jsonObject = data.get(record.getDeptNo()); });
if (null != jsonObject){
record.setProjectName(Optional.ofNullable(jsonObject.getDepartName()).orElse(""));
}
}
}
} }
return insuranceList; return insuranceList;
} }
...@@ -268,6 +259,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -268,6 +259,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
newDetail.setEmpIdcardNo(success.getReplaceEmpIdcardNo()); newDetail.setEmpIdcardNo(success.getReplaceEmpIdcardNo());
newDetail.setDeptNo(success.getReplaceDeptNo()); newDetail.setDeptNo(success.getReplaceDeptNo());
newDetail.setPost(success.getPost()); newDetail.setPost(success.getPost());
//其他状态置为空
newDetail.setIsOverdue(null);
newDetail.setIsUse(null);
newDetail.setIsEffect(null);
newDetail.setReduceHandleStatus(null);
//替换不参与结算
newDetail.setDefaultSettleId(null);
Boolean insert = this.save(newDetail); Boolean insert = this.save(newDetail);
//替换记录 //替换记录
if (insert){ if (insert){
...@@ -401,9 +399,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -401,9 +399,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
} }
} }
//记录查重校验:姓名 + 身份证号 + 保险公司 + 险种 + 保单开始日期~保单结束日期区间 是唯一(剔除退回、过期状态的记录) //记录查重校验:姓名 + 身份证号 + 保险公司 + 险种 + 保单开始日期~保单结束日期区间 是唯一(剔除退回、过期状态的记录)
//todo 时间区间 //待投保、投保中、已投保(有效、未过期)
Set<Integer> setRStatus = Sets.newHashSet(); Set<Integer> setRStatus = Sets.newHashSet();
setRStatus.add(CommonConstants.FOUR_INT); setRStatus.add(CommonConstants.FOUR_INT);
setRStatus.add(CommonConstants.FIVE_INT);
TInsuranceDetail insuranceDetail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda() TInsuranceDetail insuranceDetail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, param.getEmpName()) .eq(TInsuranceDetail::getEmpName, param.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, param.getEmpIdcardNo()) .eq(TInsuranceDetail::getEmpIdcardNo, param.getEmpIdcardNo())
...@@ -412,12 +411,35 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -412,12 +411,35 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
.eq(TInsuranceDetail::getPolicyStart, param.getPolicyStart()) .eq(TInsuranceDetail::getPolicyStart, param.getPolicyStart())
.eq(TInsuranceDetail::getPolicyEnd, param.getPolicyEnd()) .eq(TInsuranceDetail::getPolicyEnd, param.getPolicyEnd())
.notIn(TInsuranceDetail::getBuyHandleStatus, setRStatus) .notIn(TInsuranceDetail::getBuyHandleStatus, setRStatus)
.eq(TInsuranceDetail::getIsOverdue, CommonConstants.ZERO_INT)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT) .eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
.ne(TInsuranceDetail::getIsEffect,CommonConstants.ONE_INT)
.ne(TInsuranceDetail::getIsOverdue,CommonConstants.ONE_INT)
.last(CommonConstants.LAST_ONE_SQL)
); );
if (Optional.ofNullable(insuranceDetail).isPresent()){ if (Optional.ofNullable(insuranceDetail).isPresent() && !insuranceDetail.getId().equals(param.getId())){
return R.failed(InsurancesConstants.DATA_IS_EXIST); return R.failed(InsurancesConstants.DATA_IS_EXIST);
} }
//时间区间
TInsuranceDetail insuranceDetailBetween = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, param.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, param.getEmpIdcardNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, param.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, param.getInsuranceTypeName())
.notIn(TInsuranceDetail::getBuyHandleStatus, setRStatus)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
.and(
wrapper -> wrapper.between(TInsuranceDetail::getPolicyStart,LocalDateUtil.parseLocalDate(param.getPolicyStart()),LocalDateUtil.parseLocalDate(param.getPolicyEnd()))
.or()
.between(TInsuranceDetail::getPolicyEnd,LocalDateUtil.parseLocalDate(param.getPolicyStart()),LocalDateUtil.parseLocalDate(param.getPolicyEnd()))
)
.ne(TInsuranceDetail::getIsEffect,CommonConstants.ONE_INT)
.ne(TInsuranceDetail::getIsOverdue,CommonConstants.ONE_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(insuranceDetailBetween).isPresent() && !insuranceDetailBetween.getId().equals(param.getId())){
return R.failed("当前员工在["+param.getPolicyStart()+"-"+param.getPolicyEnd()+"]期间内有投保记录");
}
BeanCopyUtils.copyProperties(param,byId); BeanCopyUtils.copyProperties(param,byId);
//投保状态:待投保 //投保状态:待投保
byId.setBuyHandleStatus(CommonConstants.ONE_INT); byId.setBuyHandleStatus(CommonConstants.ONE_INT);
...@@ -488,6 +510,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -488,6 +510,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (null != jsonObject){ if (null != jsonObject){
record.setProjectName(Optional.ofNullable(jsonObject.getDepartName()).orElse("")); record.setProjectName(Optional.ofNullable(jsonObject.getDepartName()).orElse(""));
} }
//购买月数
record.setBuyMonth(LocalDateUtil.betweenMonth(record.getPolicyStart().toString(),record.getPolicyEnd().toString()));
//购买天数
record.setBuyDay(LocalDateUtil.betweenDay(record.getPolicyStart().toString(),record.getPolicyEnd().toString()));
TInsuranceDetail detail = new TInsuranceDetail(); TInsuranceDetail detail = new TInsuranceDetail();
detail.setId(record.getId()); detail.setId(record.getId());
//update状态由「待投保」置为「投保中」 //update状态由「待投保」置为「投保中」
...@@ -515,11 +541,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -515,11 +541,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
* 投保退回 * 投保退回
* *
* @param idList * @param idList
* @return {@link R<List<TInsuranceDetail>>} * @return {@link R<List<InsuranceListVO>>}
* @author licancan * @author licancan
*/ */
@Override @Override
public R<List<TInsuranceDetail>> rollBackInsurance(List<String> idList) { public R<List<InsuranceListVO>> rollBackInsurance(List<String> idList) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) { if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN); return R.failed(CommonConstants.PLEASE_LOG_IN);
...@@ -528,19 +554,34 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -528,19 +554,34 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.failed(CommonConstants.PARAM_IS_NOT_EMPTY); return R.failed(CommonConstants.PARAM_IS_NOT_EMPTY);
} }
List<TInsuranceDetail> detailList = baseMapper.selectBatchIds(idList); List<TInsuranceDetail> detailList = baseMapper.selectBatchIds(idList);
List<TInsuranceDetail> errorList = new ArrayList<>(); //返回给前端的数据
List<InsuranceListVO> errorList = new ArrayList<>();
//后端处理的数据
List<TInsuranceDetail> successList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(detailList)){ if (CollectionUtils.isNotEmpty(detailList)){
detailList.stream().forEach(e ->{ for (TInsuranceDetail detail : detailList) {
if (detail.getBuyHandleStatus() == CommonConstants.FIVE_INT){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.REDUCE_ROLLBACK_IS_NOT_ALLOW);
errorList.add(listVO);
}else {
// 记录状态置为「退回」 // 记录状态置为「退回」
e.setBuyHandleStatus(CommonConstants.FOUR_INT); detail.setBuyHandleStatus(CommonConstants.FOUR_INT);
e.setUpdateBy(user.getId()); detail.setUpdateBy(user.getId());
e.setUpdateTime(LocalDateTime.now()); detail.setUpdateTime(LocalDateTime.now());
}); successList.add(detail);
//更新 }
this.saveOrUpdateBatch(detailList);
} }
}
if (CollectionUtils.isNotEmpty(successList)){
//更新状态
this.saveOrUpdateBatch(successList);
}
//根据项目编码获取项目名称
setProjectNameByDeptNo(errorList);
//操作记录 //操作记录
addOperate(detailList,user,InsurancesConstants.ROLLBACK); addOperate(successList,user,InsurancesConstants.ROLLBACK);
return R.ok(errorList,InsurancesConstants.OPERATE_SUCCESS); return R.ok(errorList,InsurancesConstants.OPERATE_SUCCESS);
} }
...@@ -548,11 +589,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -548,11 +589,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
* 办理成功 * 办理成功
* *
* @param idList * @param idList
* @return {@link R<List<TInsuranceDetail>>} * @return {@link R<List<InsuranceListVO>>}
* @author licancan * @author licancan
*/ */
@Override @Override
public R<List<TInsuranceDetail>> successfulInsurance(List<String> idList) { public R<List<InsuranceListVO>> successfulInsurance(List<String> idList) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) { if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN); return R.failed(CommonConstants.PLEASE_LOG_IN);
...@@ -561,9 +602,107 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -561,9 +602,107 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.failed(CommonConstants.PARAM_IS_NOT_EMPTY); return R.failed(CommonConstants.PARAM_IS_NOT_EMPTY);
} }
List<TInsuranceDetail> detailList = baseMapper.selectBatchIds(idList); List<TInsuranceDetail> detailList = baseMapper.selectBatchIds(idList);
List<TInsuranceDetail> errorList = new ArrayList<>(); //返回给前端的数据
List<InsuranceListVO> errorList = new ArrayList<>();
//后端处理的数据
List<TInsuranceDetail> successList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(detailList)){ if (CollectionUtils.isNotEmpty(detailList)){
for (TInsuranceDetail detail : detailList) { for (TInsuranceDetail detail : detailList) {
//根据结算类型判断是否需要计算预估保费
//预估
if (detail.getSettleType() == CommonConstants.ZERO_INT){
//根据险种获取费率,没费率返回错误
TInsuranceType insuranceType = tInsuranceTypeService.getById(detail.getInsuranceTypeId());
//险种存不存在
if (!Optional.ofNullable(insuranceType).isPresent()){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_NAME_NOT_EXIST);
errorList.add(listVO);
}else {
TInsuranceCompany insuranceCompany = tInsuranceCompanyService.getById(insuranceType.getInsuranceCompanyId());
//保险公司存不存在
if (!Optional.ofNullable(insuranceCompany).isPresent()){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.INSURANCE_COMPANY_NAME_NOT_EXIST);
errorList.add(listVO);
}else {
if (CommonConstants.ONE_STRING.equals(insuranceCompany.getBillingType())){
//按月查费率
//计算起止时间的月数
long month = LocalDateUtil.betweenMonth(detail.getPolicyStart().toString(), detail.getPolicyEnd().toString());
TInsuranceTypeRate typeRate = tInsuranceTypeRateService.getOne(Wrappers.<TInsuranceTypeRate>query().lambda()
.eq(TInsuranceTypeRate::getInsuranceTypeId, detail.getInsuranceTypeId())
.eq(TInsuranceTypeRate::getMonth, month)
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(typeRate).isPresent()){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
errorList.add(listVO);
}else {
// 预估保费 = 费率 * 购买标准
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).multiply(new BigDecimal(typeRate.getRate())).setScale(2,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
}
//记录状态均置为「已投保」
detail.setBuyHandleStatus(CommonConstants.THREE_INT);
//记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT);
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setEstimatePremium(estimatePremium);
settle.setIsEstimatePush(CommonConstants.ZERO_INT);
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
}
}else {
//按天
//计算起止时间的天数
long day = LocalDateUtil.betweenDay(detail.getPolicyStart().toString(), detail.getPolicyEnd().toString());
//预估保费 = (购买标准 / 365) * 天数
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).divide(new BigDecimal("365")).multiply(new BigDecimal(day)).setScale(2,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
}
//记录状态均置为「已投保」
detail.setBuyHandleStatus(CommonConstants.THREE_INT);
//记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT);
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setEstimatePremium(estimatePremium);
settle.setIsEstimatePush(CommonConstants.ZERO_INT);
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
}
}
}
}
//实缴
if(detail.getSettleType() == CommonConstants.ONE_INT){
if (detail.getBuyType() == CommonConstants.THREE_INT){ if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT)); detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
} }
...@@ -572,13 +711,20 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -572,13 +711,20 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//记录的有效状态,置为「有效」 //记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT); detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT); detail.setIsOverdue(CommonConstants.ZERO_INT);
successList.add(detail);
}
}
} }
if (CollectionUtils.isNotEmpty(successList)){
//更新 //更新
this.saveOrUpdateBatch(detailList); this.saveOrUpdateBatch(successList);
//todo 根据结算类型推送ekp
//todo 根据结算类型推送预估保费到ekp
} }
//根据项目编码获取项目名称
setProjectNameByDeptNo(errorList);
//操作记录 //操作记录
addOperate(detailList,user,InsurancesConstants.SUCCESSFUL); addOperate(successList,user,InsurancesConstants.SUCCESSFUL);
return R.ok(errorList, InsurancesConstants.OPERATE_SUCCESS); return R.ok(errorList, InsurancesConstants.OPERATE_SUCCESS);
} }
...@@ -1586,6 +1732,29 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -1586,6 +1732,29 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return String.valueOf(RedisUtil.redis.opsForValue().get(CacheConstants.AREA_VALUE + areaString)); return String.valueOf(RedisUtil.redis.opsForValue().get(CacheConstants.AREA_VALUE + areaString));
} }
/**
* 根据项目编码获取项目名称
*
* @author licancan
* @param insuranceList
* @return void
*/
private void setProjectNameByDeptNo(List<InsuranceListVO> insuranceList) {
if (CollectionUtils.isNotEmpty(insuranceList)){
List<String> collect = insuranceList.stream().map(e -> e.getDeptNo()).distinct().collect(Collectors.toList());
R<SetInfoVo> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(collect);
if (null != setInfoByCodes && setInfoByCodes.getCode() == CommonConstants.SUCCESS && Common.isNotNull(setInfoByCodes.getData())) {
Map<String, ProjectSetInfoVo> data = setInfoByCodes.getData().getProjectSetInfoVoMap();
for (InsuranceListVO record : insuranceList) {
ProjectSetInfoVo jsonObject = data.get(record.getDeptNo());
if (null != jsonObject){
record.setProjectName(Optional.ofNullable(jsonObject.getDepartName()).orElse(""));
}
}
}
}
}
/** /**
* 操作记录 * 操作记录
* *
......
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