Commit ec6f9069 by 翁国栋

修改导入替换人员逻辑

parent 3f0bd8b1
...@@ -58,6 +58,7 @@ import java.time.ZoneId; ...@@ -58,6 +58,7 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -1703,7 +1704,7 @@ public class InsureContorll { ...@@ -1703,7 +1704,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){ public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId,@RequestParam("planId") String planId,@RequestParam("categoryId") String categoryId) throws IOException, ParseException {
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;
...@@ -1786,12 +1787,17 @@ public class InsureContorll { ...@@ -1786,12 +1787,17 @@ public class InsureContorll {
continue; continue;
} }
originalUser.setReplaceUser(replaceUser);
originalList.add(originalUser);
} }
originalUser.setReplaceUser(replaceUser);
originalList.add(originalUser);
} }
/*验证表格信息*/ /*验证表格信息*/
/*新被保人用户Id*/
List<String> userIdList=Lists.newArrayList(); List<String> userIdList=Lists.newArrayList();
/*原被保人*/
List<InsureUser> originaInuserUserList = Lists.newArrayList();
/*新被保人*/
List<InsureUser> replaceUserList=originalList.stream().map(InsureUser::getReplaceUser).collect(Collectors.toList());
for (InsureUser insureUser : originalList) { 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.getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getInsuredNo())
...@@ -1800,9 +1806,12 @@ public class InsureContorll { ...@@ -1800,9 +1806,12 @@ public class InsureContorll {
if(getInsureUser==null){ if(getInsureUser==null){
return ResultUtil.error(insureUser.getInsuredEContact()+"未投保"); return ResultUtil.error(insureUser.getInsuredEContact()+"未投保");
} }
originaInuserUserList.add(getInsureUser);
}
replaceUserList.stream().forEach(insureUser->{
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda() YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getName,insureUser.getReplaceUser().getInsuredName()) .eq(YgglMainEmp::getName,insureUser.getInsuredEContact())
.eq(YgglMainEmp::getZjNum,insureUser.getReplaceUser().getInsuredNo())); .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();
...@@ -1815,12 +1824,13 @@ public class InsureContorll { ...@@ -1815,12 +1824,13 @@ public class InsureContorll {
ygglMainEmp.setIsInsure(0); ygglMainEmp.setIsInsure(0);
ygglMainEmp.insert(); ygglMainEmp.insert();
} }
insureUser.setPolicyDateEnd(insurePolicy.getPolicyDateEnd());
insureUser.setOrgCode(ygglMainEmp.getOrgCode());
insureUser.setInsuredMobile(ygglMainEmp.getPhone());
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);
byte[] bytes = bos.toByteArray(); byte[] bytes = bos.toByteArray();
...@@ -1844,12 +1854,6 @@ public class InsureContorll { ...@@ -1844,12 +1854,6 @@ 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();
List<InsureUser> oldInsureUserList = insureUserMapper.selectListByIds(originalList.stream().map(InsureUser::getId).toArray(String[]::new),insurePolicy.getId(),null);
String[] oldUser = new String[oldInsureUserList.size()];
for (int i = 0; i < oldInsureUserList.size(); i++) {
oldUser[i] = oldInsureUserList.get(i).getUserId().toString();
}
Integer price = getPrice(planId, categoryId); Integer price = getPrice(planId, categoryId);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
...@@ -1877,35 +1881,31 @@ public class InsureContorll { ...@@ -1877,35 +1881,31 @@ public class InsureContorll {
//TODO 写入日志 //TODO 写入日志
return ResultUtil.error("信息填写错误,请查看日志"); return ResultUtil.error("信息填写错误,请查看日志");
} else { } else {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(userIdList.stream().toArray(String[]::new));
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById(); QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById();
ygglMainEmpList.forEach(y -> { replaceUserList.forEach(y -> {
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 * ygglMainEmpList.size())) .premium(String.valueOf(price * replaceUserList.size()))
.batchNo(batchDataMap.get("import_uuid").toString()) .batchNo(batchData.get("import_uuid").toString())
.benefitBasicPlan(planId) .benefitBasicPlan(planId)
.policyNo(orderImportInfo.get("contract_no").toString()) .policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getId()) .userId(y.getId())
.orgCode(y.getOrgCode()) .orgCode(y.getOrgCode())
.benefitOccupationCategory(categoryId) .benefitOccupationCategory(categoryId)
.insuredMobile(y.getPhone()) .insuredNo(y.getInsuredNo())
.insuredNo(y.getZjNum()) .tricycleFrameNumber(y.getTricycleFrameNumber())
.tricycleFrameNumber(oldInsureUserList.get(0).getTricycleFrameNumber()) .insuredEContact(y.getInsuredEContact())
.insuredEContact(y.getName()) .applicantEmployeeList(batchData.get("file_url").toString())
.applicantEmployeeList(batchDataMap.get("file_url").toString()) .policyDateStart(y.getPolicyDateStart())
.policyDateStart(oldInsureUserList.get(0).getPolicyDateStart()) .policyDateEnd(y.getPolicyDateEnd())
.policyDateEnd(oldInsureUserList.get(0).getPolicyDateEnd())
.applyType(3) .applyType(3)
.createTime(new Date()) .createTime(new Date())
.status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert(); .status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert();
y.setIsInsure(1);
y.insertOrUpdate();
}); });
oldInsureUserList.forEach(o -> { originaInuserUserList.forEach(o -> {
o.setReplaceTransId(batchDataMap.get("import_uuid").toString()); o.setReplaceTransId(batchData.get("import_uuid").toString());
o.updateById(); o.updateById();
}); });
...@@ -1915,6 +1915,7 @@ public class InsureContorll { ...@@ -1915,6 +1915,7 @@ public class InsureContorll {
return ResultUtil.error("导入失败"); return ResultUtil.error("导入失败");
}catch (Exception e){ }catch (Exception e){
e.printStackTrace();
throw new CustomException("导入异常"); throw new CustomException("导入异常");
}finally { }finally {
try { try {
......
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