Commit d5acd8d0 by 翁国栋

投保导入多个替换人,不同套餐

parent a970dbb3
...@@ -170,6 +170,6 @@ public class InsureUser extends Model<InsureUser> { ...@@ -170,6 +170,6 @@ public class InsureUser extends Model<InsureUser> {
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value="新被保人",example="新被保人") @ApiModelProperty(value="原被保人",example="原被保人")
private InsureUser replaceUser; private InsureUser originaUser;
} }
...@@ -124,6 +124,9 @@ public class CallBackContorll { ...@@ -124,6 +124,9 @@ public class CallBackContorll {
CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class); CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
if (callBack.getCallback_type().equals("1")) { if (callBack.getCallback_type().equals("1")) {
List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getTransId, callBack.getOrder_import_info().getThird_uuid())); List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getTransId, callBack.getOrder_import_info().getThird_uuid()));
if(insureUserList.size()<=0){
insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, callBack.getOrder_import_info().getUuid()));
}
InsurePolicy insurePolicy = InsurePolicy.builder().id(insureUserList.get(0).getPolicyId()).build().selectById(); InsurePolicy insurePolicy = InsurePolicy.builder().id(insureUserList.get(0).getPolicyId()).build().selectById();
if (callBack.getStatus().equals("1")) { if (callBack.getStatus().equals("1")) {
if (insureUserList.size() > 0) { if (insureUserList.size() > 0) {
...@@ -264,6 +267,10 @@ public class CallBackContorll { ...@@ -264,6 +267,10 @@ public class CallBackContorll {
} catch (Exception e) { } catch (Exception e) {
log.error("保全增员申请回调异常:",e); log.error("保全增员申请回调异常:",e);
throw new CustomException("保全增员申请回调异常"); throw new CustomException("保全增员申请回调异常");
//TODO 写入日志
// InsureLog.builder().requestParam(JSONObject.toJSONString(paramsMap)).type(7)
// .requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url + "/callBack/policy/CallBack")
// .returnCode(callBack.getStatus()).returnMsg(errorMsg).policyId(insurePolicy.getId()).build().insert();
} finally { } finally {
Map trueMap = Maps.newHashMap(); Map trueMap = Maps.newHashMap();
trueMap.put("status", "1"); trueMap.put("status", "1");
......
...@@ -1715,7 +1715,7 @@ public class InsureContorll { ...@@ -1715,7 +1715,7 @@ public class InsureContorll {
@PostMapping(value = "/replaceUserPolicy") @PostMapping(value = "/replaceUserPolicy")
@ApiOperation(value = "18.导入替换人员", httpMethod = "POST", notes = "导入用户") @ApiOperation(value = "18.导入替换人员", httpMethod = "POST", notes = "导入用户")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId,@RequestParam("planId") String planId,@RequestParam("categoryId") String categoryId) throws IOException, ParseException { public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId){
InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById(); InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
XSSFWorkbook xw=null; XSSFWorkbook xw=null;
...@@ -1726,8 +1726,8 @@ public class InsureContorll { ...@@ -1726,8 +1726,8 @@ public class InsureContorll {
XSSFRow titleRow = sheetAt.getRow(12); XSSFRow titleRow = sheetAt.getRow(12);
InsureUser originalUser; InsureUser originalUser;
InsureUser replaceUser; InsureUser replaceUser;
/*被保人集合*/ /*被保人集合*/
List<InsureUser> originalList=Lists.newArrayList(); List<InsureUser> replaceList=Lists.newArrayList();
// 循环获取每一行数据 // 循环获取每一行数据
for (int i = 13; i < sheetAt.getPhysicalNumberOfRows(); i++) { for (int i = 13; i < sheetAt.getPhysicalNumberOfRows(); i++) {
XSSFRow row = sheetAt.getRow(i); XSSFRow row = sheetAt.getRow(i);
...@@ -1805,30 +1805,30 @@ public class InsureContorll { ...@@ -1805,30 +1805,30 @@ public class InsureContorll {
} }
} }
originalUser.setReplaceUser(replaceUser); replaceUser.setOriginaUser(originalUser);
originalList.add(originalUser); replaceList.add(replaceUser);
} }
/*验证表格信息*/ /*验证表格信息*/
/*新被保人用户Id*/ /*新被保人用户Id*/
List<String> userIdList=Lists.newArrayList(); List<String> userIdList=Lists.newArrayList();
/*原被保人*/ /*原被保人*/
List<InsureUser> originaInuserUserList = Lists.newArrayList(); List<InsureUser> originaInuserUserList = Lists.newArrayList();
/*新被保人*/ for (InsureUser insureUser : replaceList) {
List<InsureUser> replaceUserList=originalList.stream().map(InsureUser::getReplaceUser).collect(Collectors.toList()); /*获取原投保人*/
for (InsureUser insureUser : originalList) {
InsureUser getInsureUser = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda() InsureUser getInsureUser = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda()
.eq(InsureUser::getInsuredEContact,insureUser.getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getInsuredNo()) .eq(InsureUser::getInsuredEContact,insureUser.getOriginaUser().getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getOriginaUser().getInsuredNo())
.eq(InsureUser::getInsureStatus,1).eq(InsureUser::getStatus,1).eq(InsureUser::getPolicyId,policyId).eq(InsureUser::getBenefitBasicPlan,planId) .eq(InsureUser::getInsureStatus,1).eq(InsureUser::getStatus,1).eq(InsureUser::getPolicyId,policyId));
.eq(InsureUser::getBenefitOccupationCategory,categoryId));
if(getInsureUser==null){ if(getInsureUser==null){
return ResultUtil.error(insureUser.getInsuredEContact()+"未投保"); return ResultUtil.error(insureUser.getInsuredEContact()+"未投保");
} }
/*设置保单套餐*/
insureUser.setOriginaUser(getInsureUser);
insureUser.setBenefitBasicPlan(getInsureUser.getBenefitBasicPlan());
insureUser.setBenefitOccupationCategory(getInsureUser.getBenefitOccupationCategory());
originaInuserUserList.add(getInsureUser); originaInuserUserList.add(getInsureUser);
} YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
replaceUserList.stream().forEach(insureUser->{ .eq(YgglMainEmp::getName,insureUser.getInsuredEContact())
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda() .eq(YgglMainEmp::getZjNum,insureUser.getInsuredNo()));
.eq(YgglMainEmp::getName,insureUser.getInsuredEContact())
.eq(YgglMainEmp::getZjNum,insureUser.getInsuredNo()));
if(ygglMainEmp==null){ if(ygglMainEmp==null){
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(insurePolicy.getOrgCode()).username(insureUser.getInsuredEContact()).sts(CommonEnum.U_STS_ON.getType()).build(); QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(insurePolicy.getOrgCode()).username(insureUser.getInsuredEContact()).sts(CommonEnum.U_STS_ON.getType()).build();
qyzxEmpLogin.insert(); qyzxEmpLogin.insert();
...@@ -1846,7 +1846,7 @@ public class InsureContorll { ...@@ -1846,7 +1846,7 @@ public class InsureContorll {
insureUser.setInsuredMobile(ygglMainEmp.getPhone()); insureUser.setInsuredMobile(ygglMainEmp.getPhone());
insureUser.setUserId(ygglMainEmp.getId()); insureUser.setUserId(ygglMainEmp.getId());
userIdList.add(String.valueOf(ygglMainEmp.getId())); userIdList.add(String.valueOf(ygglMainEmp.getId()));
}); }
/*上传替换文件到保司服务器*/ /*上传替换文件到保司服务器*/
String url = ""; String url = "";
xw.write(bos); xw.write(bos);
...@@ -1871,7 +1871,7 @@ public class InsureContorll { ...@@ -1871,7 +1871,7 @@ public class InsureContorll {
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2) .requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert(); .returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
Integer price = getPrice(planId, categoryId);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
bodyMap.put("contract_no", insurePolicy.getPolicyNo()); bodyMap.put("contract_no", insurePolicy.getPolicyNo());
...@@ -1899,18 +1899,19 @@ public class InsureContorll { ...@@ -1899,18 +1899,19 @@ public class InsureContorll {
return ResultUtil.error("信息填写错误,请查看日志"); return ResultUtil.error("信息填写错误,请查看日志");
} else { } else {
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById(); QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById();
replaceUserList.forEach(y -> { replaceList.forEach(y -> {
Integer price = getPrice(y.getBenefitBasicPlan(),y.getBenefitOccupationCategory());
InsureUser.builder() InsureUser.builder()
.transId("RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now)) .transId("RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.insuredName(qyzxEntInfoM.getName()) .insuredName(qyzxEntInfoM.getName())
.price(price.toString())/*前端获取的保费*/ .price(price.toString())/*前端获取的保费*/
.premium(String.valueOf(price * replaceUserList.size())) .premium(String.valueOf(price * replaceList.size()))
.batchNo(batchData.get("import_uuid").toString()) .batchNo(batchData.get("import_uuid").toString())
.benefitBasicPlan(planId) .benefitBasicPlan(y.getBenefitBasicPlan())
.policyNo(orderImportInfo.get("contract_no").toString()) .policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getUserId()) .userId(y.getUserId())
.orgCode(y.getOrgCode()) .orgCode(y.getOrgCode())
.benefitOccupationCategory(categoryId) .benefitOccupationCategory(y.getBenefitOccupationCategory())
.insuredNo(y.getInsuredNo()) .insuredNo(y.getInsuredNo())
.tricycleFrameNumber(y.getTricycleFrameNumber()) .tricycleFrameNumber(y.getTricycleFrameNumber())
.insuredEContact(y.getInsuredEContact()) .insuredEContact(y.getInsuredEContact())
......
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