Commit 5392a8a0 authored by 李灿灿's avatar 李灿灿

商险办理导入接口

parent fc7d6668
......@@ -820,17 +820,9 @@ public class InsurancesConstants {
*/
/**
* 减员退回的办理意见不能为空
*/
public static final String REFUND_MESSAGE_IS_EMPTY = "办理失败意见不能为空";
/**
* 该保单信息已被更新为减员退回
*/
/**
* 该保单信息已被更新为减员成功
* 减员/投保退回的办理意见不能为空
*/
public static final String ROLLBACK_MESSAGE_IS_EMPTY = "办理失败意见不能为空";
/**
* 该保单信息已被删除
......@@ -876,6 +868,10 @@ public class InsurancesConstants {
* 当前为投保中状态,不可办理
*/
public static final String BUY_HANDLE_STATUS_TWO_HANDLE_ERROR = "当前为投保中状态,不可办理";
/**
* 当前为非投保中状态,不可办理
*/
public static final String BUY_HANDLE_STATUS_NOT_TWO_HANDLE_ERROR = "当前为非投保中状态,不可办理";
/**
* 当前为已投保状态,不可办理
*/
......
......@@ -8,12 +8,12 @@ import java.io.Serializable;
/**
* @author zhaji
* @description 减员办理导入校验
* @description 投保成功/退回/减员办理导入校验
* @date 2022-08-22 10:15:19
*/
@Data
@Tag(name = "减员办理导入参数")
public class InsuranceRefundImportParam implements Serializable {
@Tag(name = "投保成功/退回/减员办理导入参数")
public class InsuranceHandleImportParam implements Serializable {
private static final long serialVersionUID = -2689686777914935788L;
/**
......
......@@ -244,6 +244,23 @@ public class TInsuranceDetailController {
return tInsuranceDetailService.rollBackInsurance(user,paramList);
}
/**
* 投保成功/退回办理导入
*
* @author licancan
* @param param
* @return {@link R<List<InsuranceHandleImportParam>>}
*/
@Operation(summary = "投保成功/退回办理导入", description = "投保成功/退回办理导入")
@PostMapping("/insuranceHandleImport")
public R<List<InsuranceHandleImportParam>> insuranceHandleImport(@RequestBody List<InsuranceHandleImportParam> param) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
return tInsuranceDetailService.insuranceHandleImport(user,param);
}
/**
* 办理成功
*
......@@ -410,11 +427,11 @@ public class TInsuranceDetailController {
*
* @author zhaji
* @param insuranceRefundImportList 减员信息
* @return {@link R<List<InsuranceRefundImportParam>>}
* @return {@link R<List< InsuranceHandleImportParam >>}
*/
@Operation(summary = "减员办理导入", description = "减员办理导入")
@PostMapping("/insuranceRefundImport")
public R insuranceRefundImport(@RequestBody List<InsuranceRefundImportParam> insuranceRefundImportList) {
public R insuranceRefundImport(@RequestBody List<InsuranceHandleImportParam> insuranceRefundImportList) {
return tInsuranceDetailService.insuranceRefundImport(insuranceRefundImportList);
}
......
......@@ -159,6 +159,16 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
*/
R<List<InsuranceListVO>> rollBackInsurance(YifuUser user, List<InsuranceHandleParam> paramList);
/**
* 投保成功/退回办理导入
*
* @author licancan
* @param user
* @param param
* @return {@link R<List<InsuranceHandleImportParam>>}
*/
R<List<InsuranceHandleImportParam>> insuranceHandleImport(YifuUser user,List<InsuranceHandleImportParam> param);
/**
* 办理成功
*
......@@ -262,7 +272,7 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
* @param insuranceRefundImportList 减员办理导入
* @return {@link R}
*/
R insuranceRefundImport(List<InsuranceRefundImportParam> insuranceRefundImportList);
R insuranceRefundImport(List<InsuranceHandleImportParam> insuranceRefundImportList);
/**
......
......@@ -1073,6 +1073,22 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.ok(errorList,InsurancesConstants.OPERATE_SUCCESS);
}
/**
* 投保成功/退回办理导入
*
* @param user
* @param param
* @return {@link R<List<InsuranceHandleImportParam>>}
* @author licancan
*/
@Override
public R<List<InsuranceHandleImportParam>> insuranceHandleImport(YifuUser user, List<InsuranceHandleImportParam> param) {
Map<String, List<InsuranceHandleImportParam>> map = insuranceChangeCheck(param, user,false);
List<InsuranceHandleImportParam> successList = map.get("successList");
List<InsuranceHandleImportParam> errorList = map.get("errorList");
return R.ok(errorList,InsurancesConstants.ADD_SUCCESS);
}
/**
* 办理成功
*
......@@ -3185,18 +3201,18 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
*/
@Transactional(rollbackFor = Exception.class)
@Override
public R insuranceRefundImport(List<InsuranceRefundImportParam> insuranceRefundImportList) {
public R insuranceRefundImport(List<InsuranceHandleImportParam> insuranceRefundImportList) {
YifuUser user = SecurityUtils.getUser();
if (!Common.isNotEmpty(insuranceRefundImportList)) {
return R.failed(InsurancesConstants.INSURANCE_REFUND_IMPORT_LIST_IS_EMPTY);
}
Map<String, List<InsuranceRefundImportParam>> map = insuranceChangeCheck(insuranceRefundImportList, user);
List<InsuranceRefundImportParam> successList = map.get("successList");
List<InsuranceRefundImportParam> errorList = map.get("errorList");
Map<String, List<InsuranceHandleImportParam>> map = insuranceChangeCheck(insuranceRefundImportList, user,true);
List<InsuranceHandleImportParam> successList = map.get("successList");
List<InsuranceHandleImportParam> errorList = map.get("errorList");
//减员退回
List<TInsuranceOperate> operateList =new ArrayList<>(16);
if (CollectionUtils.isNotEmpty(successList)) {
for (InsuranceRefundImportParam param : successList) {
for (InsuranceHandleImportParam param : successList) {
TInsuranceOperate operate = new TInsuranceOperate();
LambdaUpdateWrapper<TInsuranceRefund> refund = new LambdaUpdateWrapper<>();
refund.eq(TInsuranceRefund :: getInsDetailId ,param.getId());
......@@ -4246,17 +4262,23 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
/**
* 减员办理校验
* 投保成功/退回/减员办理校验
*
* @author zhaji
* @param settleMonthCheckList 减员办理校验
* @return {@link R}
* @param checkList 投保成功/退回/减员办理校验
* @param user
* @param flag true 减员 false 投保成功/退回
* @return {@link Map<String, List<InsuranceHandleImportParam>}
*/
private Map<String,List<InsuranceRefundImportParam>> insuranceChangeCheck(List<InsuranceRefundImportParam> settleMonthCheckList,YifuUser user) {
Map<String,List<InsuranceRefundImportParam>> map = new HashMap<>(16);
List<InsuranceRefundImportParam> errorList = new ArrayList<>();
List<InsuranceRefundImportParam> successList = new ArrayList<>();
for (InsuranceRefundImportParam param : settleMonthCheckList) {
private Map<String,List<InsuranceHandleImportParam>> insuranceChangeCheck(List<InsuranceHandleImportParam> checkList, YifuUser user,Boolean flag) {
Map<String,List<InsuranceHandleImportParam>> map = new HashMap<>(16);
List<InsuranceHandleImportParam> errorList = new ArrayList<>();
List<InsuranceHandleImportParam> successList = new ArrayList<>();
List<InsuranceHandleImportParam> distinctList = checkList.stream().distinct().collect(Collectors.toList());
//定义外层循环标识,方便去重的时候跳出
outer:
for (int i = 0; i < distinctList.size(); i++) {
InsuranceHandleImportParam param = distinctList.get(i);
//办理结果
String handType = param.getHandType();
if(StringUtils.isBlank(handType)){
......@@ -4272,7 +4294,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//办理意见
String remark = param.getRemark();
if(InsurancesConstants.FAILED.equals(handType) && StringUtils.isBlank(remark)){
param.setErrorMessage(InsurancesConstants.REFUND_MESSAGE_IS_EMPTY);
param.setErrorMessage(InsurancesConstants.ROLLBACK_MESSAGE_IS_EMPTY);
errorList.add(param);
continue;
}
......@@ -4348,15 +4370,33 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
errorList.add(param);
continue;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司名称、险种名称、保单开始日期、保单结束日期、购买标准 去重
for (int j = 0; j < distinctList.size(); j++) {
InsuranceHandleImportParam 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);
errorList.add(param);
continue outer;
}
}
LambdaQueryWrapper<TInsuranceDetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TInsuranceDetail ::getDeleteFlag,CommonConstants.ZERO_INT)
.eq(TInsuranceDetail :: getEmpName,empName)
.eq(TInsuranceDetail :: getEmpIdcardNo,empIdCardNo)
.eq(TInsuranceDetail ::getInsuranceTypeName,insuranceTypeName)
.eq(TInsuranceDetail :: getInsuranceCompanyName,insuranceCompanyName)
.eq(TInsuranceDetail :: getBuyStandard,buyStandard)
.eq(TInsuranceDetail :: getPolicyStart,LocalDateUtil.parseLocalDate(policyStart) )
.eq(TInsuranceDetail :: getPolicyEnd,LocalDateUtil.parseLocalDate(policyEnd))
queryWrapper.eq(TInsuranceDetail::getDeleteFlag,CommonConstants.ZERO_INT)
.eq(TInsuranceDetail::getEmpName,empName)
.eq(TInsuranceDetail::getEmpIdcardNo,empIdCardNo)
.eq(TInsuranceDetail::getInsuranceTypeName,insuranceTypeName)
.eq(TInsuranceDetail::getInsuranceCompanyName,insuranceCompanyName)
.eq(TInsuranceDetail::getBuyStandard,buyStandard)
.eq(TInsuranceDetail::getPolicyStart,LocalDateUtil.parseLocalDate(policyStart) )
.eq(TInsuranceDetail::getPolicyEnd,LocalDateUtil.parseLocalDate(policyEnd))
.orderByDesc(TInsuranceDetail::getUpdateTime)
.last(CommonConstants.LAST_ONE_SQL);
TInsuranceDetail insuranceDetail = getOne(queryWrapper);
......@@ -4375,6 +4415,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
errorList.add(param);
continue;
}
if (flag){
//减员办理
//投保办理状态
Integer buyHandleStatus = insuranceDetail.getBuyHandleStatus();
//减员状态
......@@ -4423,20 +4465,18 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
continue;
}
}
}else {
//投保成功/退回办理
//商险不是投保中,无法办理
if (CommonConstants.TWO_INT != insuranceDetail.getBuyHandleStatus()){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_STATUS_NOT_TWO_HANDLE_ERROR);
errorList.add(param);
continue;
}
}
param.setId(detailId);
boolean b = successList.stream().anyMatch(
u -> u.getEmpName().equals(param.getEmpName())
&& u.getEmpIdcardNo().equals(param.getEmpIdcardNo())
&& u.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())
&& u.getInsuranceTypeName().equals(param.getInsuranceTypeName())
&& u.getPolicyStart().equals(param.getPolicyStart())
&& u.getPolicyEnd().equals(param.getPolicyEnd())
&& u.getBuyStandard().equals(param.getBuyStandard())
);
if(!b){
successList.add(param);
}
}
map.put("successList",successList);
map.put("errorList",errorList);
return map;
......
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