Commit ec6f9069 by 翁国栋

修改导入替换人员逻辑

parent 3f0bd8b1
......@@ -58,6 +58,7 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.alibaba.fastjson.JSONObject;
......@@ -1703,7 +1704,7 @@ public class InsureContorll {
@PostMapping(value = "/replaceUserPolicy")
@ApiOperation(value = "18.导入替换人员", httpMethod = "POST", notes = "导入用户")
@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();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XSSFWorkbook xw=null;
......@@ -1786,12 +1787,17 @@ public class InsureContorll {
continue;
}
}
originalUser.setReplaceUser(replaceUser);
originalList.add(originalUser);
}
}
/*验证表格信息*/
/*新被保人用户Id*/
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) {
InsureUser getInsureUser = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda()
.eq(InsureUser::getInsuredEContact,insureUser.getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getInsuredNo())
......@@ -1800,9 +1806,12 @@ public class InsureContorll {
if(getInsureUser==null){
return ResultUtil.error(insureUser.getInsuredEContact()+"未投保");
}
originaInuserUserList.add(getInsureUser);
}
replaceUserList.stream().forEach(insureUser->{
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getName,insureUser.getReplaceUser().getInsuredName())
.eq(YgglMainEmp::getZjNum,insureUser.getReplaceUser().getInsuredNo()));
.eq(YgglMainEmp::getName,insureUser.getInsuredEContact())
.eq(YgglMainEmp::getZjNum,insureUser.getInsuredNo()));
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.insert();
......@@ -1815,12 +1824,13 @@ public class InsureContorll {
ygglMainEmp.setIsInsure(0);
ygglMainEmp.insert();
}
insureUser.setPolicyDateEnd(insurePolicy.getPolicyDateEnd());
insureUser.setOrgCode(ygglMainEmp.getOrgCode());
insureUser.setInsuredMobile(ygglMainEmp.getPhone());
insureUser.setUserId(ygglMainEmp.getId());
userIdList.add(String.valueOf(ygglMainEmp.getId()));
}
});
/*上传替换文件到保司服务器*/
/*保司返回地址*/
String url = "";
xw.write(bos);
byte[] bytes = bos.toByteArray();
......@@ -1844,12 +1854,6 @@ public class InsureContorll {
.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();
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);
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
......@@ -1877,35 +1881,31 @@ public class InsureContorll {
//TODO 写入日志
return ResultUtil.error("信息填写错误,请查看日志");
} else {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(userIdList.stream().toArray(String[]::new));
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById();
ygglMainEmpList.forEach(y -> {
replaceUserList.forEach(y -> {
InsureUser.builder()
.transId("RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.insuredName(qyzxEntInfoM.getName())
.price(price.toString())/*前端获取的保费*/
.premium(String.valueOf(price * ygglMainEmpList.size()))
.batchNo(batchDataMap.get("import_uuid").toString())
.premium(String.valueOf(price * replaceUserList.size()))
.batchNo(batchData.get("import_uuid").toString())
.benefitBasicPlan(planId)
.policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getId())
.orgCode(y.getOrgCode())
.benefitOccupationCategory(categoryId)
.insuredMobile(y.getPhone())
.insuredNo(y.getZjNum())
.tricycleFrameNumber(oldInsureUserList.get(0).getTricycleFrameNumber())
.insuredEContact(y.getName())
.applicantEmployeeList(batchDataMap.get("file_url").toString())
.policyDateStart(oldInsureUserList.get(0).getPolicyDateStart())
.policyDateEnd(oldInsureUserList.get(0).getPolicyDateEnd())
.insuredNo(y.getInsuredNo())
.tricycleFrameNumber(y.getTricycleFrameNumber())
.insuredEContact(y.getInsuredEContact())
.applicantEmployeeList(batchData.get("file_url").toString())
.policyDateStart(y.getPolicyDateStart())
.policyDateEnd(y.getPolicyDateEnd())
.applyType(3)
.createTime(new Date())
.status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert();
y.setIsInsure(1);
y.insertOrUpdate();
});
oldInsureUserList.forEach(o -> {
o.setReplaceTransId(batchDataMap.get("import_uuid").toString());
originaInuserUserList.forEach(o -> {
o.setReplaceTransId(batchData.get("import_uuid").toString());
o.updateById();
});
......@@ -1915,6 +1915,7 @@ public class InsureContorll {
return ResultUtil.error("导入失败");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("导入异常");
}finally {
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