Commit 6369d972 by 翁国栋

导入方案处理

parent 9659298e
...@@ -167,8 +167,8 @@ public class InsureContorll { ...@@ -167,8 +167,8 @@ public class InsureContorll {
return paramsMap; return paramsMap;
} }
private static String getPlanType(String category){ private static String getPlanType(String category) {
switch (category){ switch (category) {
case "63119": case "63119":
return "A类"; return "A类";
case "63120": case "63120":
...@@ -185,7 +185,7 @@ public class InsureContorll { ...@@ -185,7 +185,7 @@ public class InsureContorll {
public Result<Object> insured_add(@RequestBody InsureDto insureDto) { public Result<Object> insured_add(@RequestBody InsureDto insureDto) {
InsureProduct insureProduct = InsureProduct.builder().id(Integer.parseInt(insureDto.getProductId())).build().selectById(); InsureProduct insureProduct = InsureProduct.builder().id(Integer.parseInt(insureDto.getProductId())).build().selectById();
List<InsureProductPlan> priceList = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda() List<InsureProductPlan> priceList = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda()
.eq(InsureProductPlan::getProductId,insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag,0)); .eq(InsureProductPlan::getProductId, insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag, 0));
if (insureProduct == null) { if (insureProduct == null) {
return ResultUtil.error("产品不存在"); return ResultUtil.error("产品不存在");
} }
...@@ -204,9 +204,9 @@ public class InsureContorll { ...@@ -204,9 +204,9 @@ public class InsureContorll {
if (insureUserList.size() > 0) { if (insureUserList.size() > 0) {
String name = ""; String name = "";
for (InsureUser insureUser : insureUserList) { for (InsureUser insureUser : insureUserList) {
name+=insureUser.getInsuredEContact()+','; name += insureUser.getInsuredEContact() + ',';
} }
return ResultUtil.error("被保人"+name+"当月已投保"); return ResultUtil.error("被保人" + name + "当月已投保");
} }
} }
Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant()); Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
...@@ -219,7 +219,7 @@ public class InsureContorll { ...@@ -219,7 +219,7 @@ public class InsureContorll {
return ResultUtil.error("请选择计划和职业类别"); return ResultUtil.error("请选择计划和职业类别");
} }
insureDto.getPlans().forEach(i -> { insureDto.getPlans().forEach(i -> {
i.setPrice(priceList.stream().filter(v->v.getId()==i.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getPrice()); i.setPrice(priceList.stream().filter(v -> v.getId() == i.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getPrice());
insureDto.setTotalPrice(i.getPrice() * i.getUserIds().length + (insureDto.getTotalPrice() == null ? 0 : insureDto.getTotalPrice())); insureDto.setTotalPrice(i.getPrice() * i.getUserIds().length + (insureDto.getTotalPrice() == null ? 0 : insureDto.getTotalPrice()));
}); });
quotations.put("trans_id", "MB_" + dtf2.format(now));/*报价请求流水号*/ quotations.put("trans_id", "MB_" + dtf2.format(now));/*报价请求流水号*/
...@@ -268,7 +268,7 @@ public class InsureContorll { ...@@ -268,7 +268,7 @@ public class InsureContorll {
/*人员清单填被保人员*/ /*人员清单填被保人员*/
String url = creaXSSFWorkbook(insureDto.getPlans(), insureDto.getPolicyDateStart(),priceList); String url = creaXSSFWorkbook(insureDto.getPlans(), insureDto.getPolicyDateStart(), priceList);
if (!StringUtil.isNotBlank(url)) { if (!StringUtil.isNotBlank(url)) {
return ResultUtil.error("文件错误"); return ResultUtil.error("文件错误");
} }
...@@ -299,7 +299,7 @@ public class InsureContorll { ...@@ -299,7 +299,7 @@ public class InsureContorll {
/*被保人员 填被保企业信息*/ /*被保人员 填被保企业信息*/
ArrayList<Map> insuredArray = new ArrayList<>(); ArrayList<Map> insuredArray = new ArrayList<>();
insureDto.getPlans().forEach(p -> { insureDto.getPlans().forEach(p -> {
InsureProductPlan plan = priceList.stream().filter(v->v.getId()==p.getBenefitBasicPlan()).collect(Collectors.toList()).get(0); InsureProductPlan plan = priceList.stream().filter(v -> v.getId() == p.getBenefitBasicPlan()).collect(Collectors.toList()).get(0);
List<InsurePlan> insurePlansList = insurePlanMapper.findPlanByIds(JSON.parseArray(plan.getPlanJson(), String.class)); List<InsurePlan> insurePlansList = insurePlanMapper.findPlanByIds(JSON.parseArray(plan.getPlanJson(), String.class));
Map insured = Maps.newHashMap(); Map insured = Maps.newHashMap();
insured.put("trans_id", "PI_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now) + "_" + UUID.randomUUID().toString().replace("-", "")); insured.put("trans_id", "PI_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now) + "_" + UUID.randomUUID().toString().replace("-", ""));
...@@ -313,12 +313,12 @@ public class InsureContorll { ...@@ -313,12 +313,12 @@ public class InsureContorll {
insured.put("insured_zm_openid", ""); insured.put("insured_zm_openid", "");
insured.put("benefit_EL_employee_number_t", p.getUserIds().length); insured.put("benefit_EL_employee_number_t", p.getUserIds().length);
insured.put("insured_province_city_thr",insureApplicant.getApplicantProvinceCity());/*省市区*/ insured.put("insured_province_city_thr", insureApplicant.getApplicantProvinceCity());/*省市区*/
/*新增项目*/ /*新增项目*/
insured.put("benefit_basic_plan", insurePlansList.stream().filter(v->v.getType().equals("BENEFIT_BASIC_PLAN")).collect(Collectors.toList()).get(0).getPlanId()); insured.put("benefit_basic_plan", insurePlansList.stream().filter(v -> v.getType().equals("BENEFIT_BASIC_PLAN")).collect(Collectors.toList()).get(0).getPlanId());
insured.put("benefit_occupation_category", p.getBenefitOccupationCategory()); insured.put("benefit_occupation_category", p.getBenefitOccupationCategory());
insured.put("benefit_3rd_party_lib",insurePlansList.stream().filter(v->v.getType().equals("BENEFIT_3RD_PARTY_LIB")).collect(Collectors.toList()).get(0).getPlanId()); insured.put("benefit_3rd_party_lib", insurePlansList.stream().filter(v -> v.getType().equals("BENEFIT_3RD_PARTY_LIB")).collect(Collectors.toList()).get(0).getPlanId());
insured.put("benefit_24hours",insurePlansList.stream().filter(v->v.getType().equals("BENEFIT_24HOURS")).collect(Collectors.toList()).get(0).getPlanId()); insured.put("benefit_24hours", insurePlansList.stream().filter(v -> v.getType().equals("BENEFIT_24HOURS")).collect(Collectors.toList()).get(0).getPlanId());
insuredArray.add(insured); insuredArray.add(insured);
}); });
quotations.put("insured", insuredArray); quotations.put("insured", insuredArray);
...@@ -392,7 +392,6 @@ public class InsureContorll { ...@@ -392,7 +392,6 @@ public class InsureContorll {
insureUser.setInsureStatus(3); insureUser.setInsureStatus(3);
insureUser.setStatus("2"); insureUser.setStatus("2");
} }
// insureUser.setBenefitBasicPlan(p.getBenefitBasicPlan());
insureUser.setProductPlanId(p.getBenefitBasicPlan()); insureUser.setProductPlanId(p.getBenefitBasicPlan());
insureUser.setUserId(y.getId()); insureUser.setUserId(y.getId());
insureUser.setOrgCode(y.getOrgCode()); insureUser.setOrgCode(y.getOrgCode());
...@@ -462,13 +461,13 @@ public class InsureContorll { ...@@ -462,13 +461,13 @@ public class InsureContorll {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById(); InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
InsureProduct insureProduct = InsureProduct.builder().id(insurePolicy.getProductId()).build().selectById(); InsureProduct insureProduct = InsureProduct.builder().id(insurePolicy.getProductId()).build().selectById();
List<InsureProductPlan> priceList = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda() List<InsureProductPlan> priceList = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda()
.eq(InsureProductPlan::getProductId,insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag,0)); .eq(InsureProductPlan::getProductId, insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag, 0));
if (insurePolicy == null) { if (insurePolicy == null) {
return ResultUtil.error("保单不存在"); return ResultUtil.error("保单不存在");
} }
try { try {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook1(insureDto,priceList); String url = creaXSSFWorkbook1(insureDto, priceList);
log.info("保全增员文件地址", url); log.info("保全增员文件地址", url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
Map bodyMap = Maps.newHashMap(); Map bodyMap = Maps.newHashMap();
...@@ -490,8 +489,8 @@ public class InsureContorll { ...@@ -490,8 +489,8 @@ public class InsureContorll {
InsureUser.builder() InsureUser.builder()
.transId(bodyMap.get("third_uuid").toString()) .transId(bodyMap.get("third_uuid").toString())
.insuredName(qyzxEntInfoM.getName()) .insuredName(qyzxEntInfoM.getName())
.price(priceList.stream().filter(v->v.getId()==insureDto.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getPrice())/*前端获取的保费*/ .price(priceList.stream().filter(v -> v.getId() == insureDto.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getPrice())/*前端获取的保费*/
.premium(priceList.stream().filter(v->v.getId()==insureDto.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getPrice() * insureDto.getUserIds().length) .premium(priceList.stream().filter(v -> v.getId() == insureDto.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getPrice() * insureDto.getUserIds().length)
// .batchNo(data.get("import_uuid").toString()) // .batchNo(data.get("import_uuid").toString())
// .benefitBasicPlan(insureDto.getBenefitBasicPlan()) // .benefitBasicPlan(insureDto.getBenefitBasicPlan())
.productPlanId(insureDto.getBenefitBasicPlan()) .productPlanId(insureDto.getBenefitBasicPlan())
...@@ -615,7 +614,7 @@ public class InsureContorll { ...@@ -615,7 +614,7 @@ public class InsureContorll {
insureDto.setUserIds(new String[]{String.valueOf(y.getId())}); insureDto.setUserIds(new String[]{String.valueOf(y.getId())});
} }
} }
List<InsureUser> oldInsureUserList = insureUserMapper.selectListByIds(insureDto.getOldIds(),insurePolicy.getId(),null); List<InsureUser> oldInsureUserList = insureUserMapper.selectListByIds(insureDto.getOldIds(), insurePolicy.getId(), null);
String[] oldUser = new String[oldInsureUserList.size()]; String[] oldUser = new String[oldInsureUserList.size()];
for (int i = 0; i < oldInsureUserList.size(); i++) { for (int i = 0; i < oldInsureUserList.size(); i++) {
oldUser[i] = oldInsureUserList.get(i).getUserId().toString(); oldUser[i] = oldInsureUserList.get(i).getUserId().toString();
...@@ -827,7 +826,7 @@ public class InsureContorll { ...@@ -827,7 +826,7 @@ public class InsureContorll {
@PostMapping(value = "/importUser") @PostMapping(value = "/importUser")
@ApiOperation(value = "12.导入用户--运营后台", httpMethod = "POST", notes = "导入用户") @ApiOperation(value = "12.导入用户--运营后台", httpMethod = "POST", notes = "导入用户")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<Object> importUser(@RequestParam("orgCode") String orgCode,@RequestParam("policyId") Integer policyId, @RequestParam("file") MultipartFile file) { public Result<Object> importUser(@RequestParam("orgCode") String orgCode, @RequestParam("policyId") Integer policyId, @RequestParam("file") MultipartFile file) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(orgCode)).build().selectById(); QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(orgCode)).build().selectById();
if (company == null) { if (company == null) {
...@@ -839,7 +838,7 @@ public class InsureContorll { ...@@ -839,7 +838,7 @@ public class InsureContorll {
List<YgglMainEmp> yg = Lists.newArrayList(); List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList = Lists.newArrayList(); List<YgglMainEmp> selectUserList = Lists.newArrayList();
List<YgglMainEmp> allList = Lists.newArrayList(); List<YgglMainEmp> allList = Lists.newArrayList();
XSSFWorkbook xw=null; XSSFWorkbook xw = null;
try { try {
xw = new XSSFWorkbook(file.getInputStream()); xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0); XSSFSheet sheetAt = xw.getSheetAt(0);
...@@ -916,7 +915,7 @@ public class InsureContorll { ...@@ -916,7 +915,7 @@ public class InsureContorll {
List<String> idNumList = userList.stream().map(YgglMainEmp::getZjNum).collect(Collectors.toList()); List<String> idNumList = userList.stream().map(YgglMainEmp::getZjNum).collect(Collectors.toList());
List<YgglMainEmp> newList = yg.stream().filter(v -> !idNumList.contains(v.getZjNum())).collect(Collectors.toList()); List<YgglMainEmp> newList = yg.stream().filter(v -> !idNumList.contains(v.getZjNum())).collect(Collectors.toList());
if (newList.size() > 0) { if (newList.size() > 0) {
newList.forEach(u ->{ newList.forEach(u -> {
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(company.getId()).username(u.getName()).sts(CommonEnum.U_STS_ON.getType()).build(); QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(company.getId()).username(u.getName()).sts(CommonEnum.U_STS_ON.getType()).build();
qyzxEmpLogin.insert(); qyzxEmpLogin.insert();
u.setEmpNum(qyzxEmpLogin.getId()); u.setEmpNum(qyzxEmpLogin.getId());
...@@ -935,19 +934,19 @@ public class InsureContorll { ...@@ -935,19 +934,19 @@ public class InsureContorll {
if (insureUserList.size() > 0) { if (insureUserList.size() > 0) {
String name = ""; String name = "";
for (InsureUser insureUser : insureUserList) { for (InsureUser insureUser : insureUserList) {
name+=insureUser.getInsuredEContact()+','; name += insureUser.getInsuredEContact() + ',';
} }
return ResultUtil.error("被保人"+name+"当月已投保"); return ResultUtil.error("被保人" + name + "当月已投保");
} }
return ResultUtil.data(allList, "导入成功"); return ResultUtil.data(allList, "导入成功");
} catch (IOException e) { } catch (IOException e) {
log.error("一键校验异常:", e); log.error("一键校验异常:", e);
throw new CustomException("一键校验异常"); throw new CustomException("一键校验异常");
}catch (Exception e){ } catch (Exception e) {
new CustomException("导入用户异常"); new CustomException("导入用户异常");
}finally { } finally {
if(xw!=null){ if (xw != null) {
try { try {
xw.close(); xw.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -961,13 +960,13 @@ public class InsureContorll { ...@@ -961,13 +960,13 @@ public class InsureContorll {
// if (message.size() > 0) { // if (message.size() > 0) {
// return ResultUtil.data(selectUserList, JSONObject.toJSONString(message) + "已投过保"); // return ResultUtil.data(selectUserList, JSONObject.toJSONString(message) + "已投过保");
// } // }
return ResultUtil.error( "导入错误"); return ResultUtil.error("导入错误");
} }
@PostMapping(value = "/importUserClient") @PostMapping(value = "/importUserClient")
@ApiOperation(value = "13.导入用户--8小时后台", httpMethod = "POST", notes = "导入用户") @ApiOperation(value = "13.导入用户--8小时后台", httpMethod = "POST", notes = "导入用户")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<Object> importUserClient(@CurrentUser UserBean userBean,@RequestParam("policyId")Integer policyId, @RequestParam("file") MultipartFile file) { public Result<Object> importUserClient(@CurrentUser UserBean userBean, @RequestParam("policyId") Integer policyId, @RequestParam("file") MultipartFile file) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(userBean.getOrgCode())).build().selectById(); QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(userBean.getOrgCode())).build().selectById();
if (company == null) { if (company == null) {
...@@ -979,9 +978,9 @@ public class InsureContorll { ...@@ -979,9 +978,9 @@ public class InsureContorll {
List<YgglMainEmp> yg = Lists.newArrayList(); List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList = Lists.newArrayList(); List<YgglMainEmp> selectUserList = Lists.newArrayList();
List<YgglMainEmp> allList = Lists.newArrayList(); List<YgglMainEmp> allList = Lists.newArrayList();
XSSFWorkbook xw=null; XSSFWorkbook xw = null;
try { try {
xw = new XSSFWorkbook(file.getInputStream()); xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0); XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0 //默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0); XSSFRow titleRow = sheetAt.getRow(0);
...@@ -1056,7 +1055,7 @@ public class InsureContorll { ...@@ -1056,7 +1055,7 @@ public class InsureContorll {
List<String> idNumList = userList.stream().map(YgglMainEmp::getZjNum).collect(Collectors.toList()); List<String> idNumList = userList.stream().map(YgglMainEmp::getZjNum).collect(Collectors.toList());
List<YgglMainEmp> newList = yg.stream().filter(v -> !idNumList.contains(v.getZjNum())).collect(Collectors.toList()); List<YgglMainEmp> newList = yg.stream().filter(v -> !idNumList.contains(v.getZjNum())).collect(Collectors.toList());
if (newList.size() > 0) { if (newList.size() > 0) {
newList.forEach(u ->{ newList.forEach(u -> {
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(company.getId()).username(u.getName()).sts(CommonEnum.U_STS_ON.getType()).build(); QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(company.getId()).username(u.getName()).sts(CommonEnum.U_STS_ON.getType()).build();
qyzxEmpLogin.insert(); qyzxEmpLogin.insert();
u.setEmpNum(qyzxEmpLogin.getId()); u.setEmpNum(qyzxEmpLogin.getId());
...@@ -1075,15 +1074,15 @@ public class InsureContorll { ...@@ -1075,15 +1074,15 @@ public class InsureContorll {
if (insureUserList.size() > 0) { if (insureUserList.size() > 0) {
String name = ""; String name = "";
for (InsureUser insureUser : insureUserList) { for (InsureUser insureUser : insureUserList) {
name+=insureUser.getInsuredEContact()+','; name += insureUser.getInsuredEContact() + ',';
} }
return ResultUtil.error("被保人"+name+"当月已投保"); return ResultUtil.error("被保人" + name + "当月已投保");
} }
} catch (IOException e) { } catch (IOException e) {
log.error("导入用户:", e); log.error("导入用户:", e);
throw new CustomException("导入用户"); throw new CustomException("导入用户");
}finally { } finally {
if(xw!=null){ if (xw != null) {
try { try {
xw.close(); xw.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -1113,9 +1112,11 @@ public class InsureContorll { ...@@ -1113,9 +1112,11 @@ public class InsureContorll {
if (insureProduct == null) { if (insureProduct == null) {
return ResultUtil.error("产品不存在"); return ResultUtil.error("产品不存在");
} }
XSSFWorkbook xw=null; List<InsureProductPlan> insureProductPlans = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda()
.eq(InsureProductPlan::getProductId, insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag, 0));
XSSFWorkbook xw = null;
try { try {
xw = new XSSFWorkbook(file.getInputStream()); xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0); XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0 //默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0); XSSFRow titleRow = sheetAt.getRow(0);
...@@ -1158,9 +1159,11 @@ public class InsureContorll { ...@@ -1158,9 +1159,11 @@ public class InsureContorll {
} }
break; break;
case "方案名称": case "方案名称":
PlanEnum plan = PlanEnum.getEnumOfName(ExcelUtils.getString(cell).trim()); InsureProductPlan insureProductPlan = insureProductPlans.stream().filter(v -> v.getName().equals(ExcelUtils.getString(cell).trim())).findFirst().orElse(null);
user.setBenefitBasicPlan(plan.getPlan()); if (insureProductPlan == null) {
user.setBenefitOccupationCategory(plan.getCategory()); throw new CustomException("方案不存在");
}
user.setProductPlanId(insureProductPlan.getId());
break; break;
case "有效期起": case "有效期起":
Date start = null; Date start = null;
...@@ -1217,8 +1220,8 @@ public class InsureContorll { ...@@ -1217,8 +1220,8 @@ public class InsureContorll {
user.setPrice(Double.parseDouble(ExcelUtils.getString(cell))); user.setPrice(Double.parseDouble(ExcelUtils.getString(cell)));
break; break;
case "备注": case "备注":
if(!StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))){ if (!StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
user.setRemake(ExcelUtils.getString(cell)); user.setRemake(ExcelUtils.getString(cell));
} }
break; break;
} }
...@@ -1239,7 +1242,7 @@ public class InsureContorll { ...@@ -1239,7 +1242,7 @@ public class InsureContorll {
if (!dataMap.get("product_code").equals(insureProduct.getProductCodeId())) { if (!dataMap.get("product_code").equals(insureProduct.getProductCodeId())) {
return ResultUtil.error("导入的保单产品和选择的保单产品不一致"); return ResultUtil.error("导入的保单产品和选择的保单产品不一致");
} }
if(!dataMap.get("corporate_applicant_name").equals(company.getAttestName())){ if (!dataMap.get("corporate_applicant_name").equals(company.getAttestName())) {
return ResultUtil.error("导入的保单投保人和企业投保人不一样"); return ResultUtil.error("导入的保单投保人和企业投保人不一样");
} }
policy.setProductId(insureProduct.getId()); policy.setProductId(insureProduct.getId());
...@@ -1267,11 +1270,11 @@ public class InsureContorll { ...@@ -1267,11 +1270,11 @@ public class InsureContorll {
} }
for (InsureUser insureUser : userList) { for (InsureUser insureUser : userList) {
InsureUser getInsurer = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda() InsureUser getInsurer = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda()
.eq(InsureUser::getPolicyId,policy.getId()).eq(InsureUser::getStatus,1) .eq(InsureUser::getPolicyId, policy.getId()).eq(InsureUser::getStatus, 1)
.eq(InsureUser::getInsureStatus,1).eq(InsureUser::getPolicyDateStart,insureUser.getPolicyDateStart()) .eq(InsureUser::getInsureStatus, 1).eq(InsureUser::getPolicyDateStart, insureUser.getPolicyDateStart())
.eq(InsureUser::getPolicyDateEnd,insureUser.getPolicyDateEnd()) .eq(InsureUser::getPolicyDateEnd, insureUser.getPolicyDateEnd())
.eq(InsureUser::getInsuredEContact,insureUser.getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getInsuredNo())); .eq(InsureUser::getInsuredEContact, insureUser.getInsuredEContact()).eq(InsureUser::getInsuredNo, insureUser.getInsuredNo()));
if(getInsurer!=null){ if (getInsurer != null) {
continue; continue;
} }
/*根据名字,身份,所属企业获取员工*/ /*根据名字,身份,所属企业获取员工*/
...@@ -1303,20 +1306,20 @@ public class InsureContorll { ...@@ -1303,20 +1306,20 @@ public class InsureContorll {
insureUser.setCreateTime(new Date()); insureUser.setCreateTime(new Date());
insureUser.insert(); insureUser.insert();
/*判断批改状态*/ /*判断批改状态*/
if(insureUser.getApplyType()==3){ if (insureUser.getApplyType() == 3) {
if(StringUtils.isNullOrEmpty(insureUser.getRemake())){ if (StringUtils.isNullOrEmpty(insureUser.getRemake())) {
return ResultUtil.data("批改状态下备注不能为空"); return ResultUtil.data("批改状态下备注不能为空");
} }
if(insureUser.getRemake().indexOf("被保险人信息批改-原被保险人,")!=-1){ if (insureUser.getRemake().indexOf("被保险人信息批改-原被保险人,") != -1) {
String newStr= insureUser.getRemake().substring(insureUser.getRemake().indexOf(",")+1,insureUser.getRemake().length()); String newStr = insureUser.getRemake().substring(insureUser.getRemake().indexOf(",") + 1, insureUser.getRemake().length());
String[] arr = newStr.split("/"); String[] arr = newStr.split("/");
if(arr[0].equals(insureUser.getInsuredEContact())&&arr[2].equals(insureUser.getInsuredNo())){ if (arr[0].equals(insureUser.getInsuredEContact()) && arr[2].equals(insureUser.getInsuredNo())) {
return ResultUtil.data("批改状态下替换人和被替换人不能相同"); return ResultUtil.data("批改状态下替换人和被替换人不能相同");
} }
/*更新人员投保状态*/ /*更新人员投保状态*/
InsureUser.builder().status("2").insureStatus(2).build().update(new QueryWrapper<InsureUser>() InsureUser.builder().status("2").insureStatus(2).build().update(new QueryWrapper<InsureUser>()
.lambda().eq(InsureUser::getInsuredNo,arr[2]).eq(InsureUser::getInsuredEContact,arr[0])); .lambda().eq(InsureUser::getInsuredNo, arr[2]).eq(InsureUser::getInsuredEContact, arr[0]));
ygglMainEmp.builder().isInsure(2).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId,insureUser.getUserId())); ygglMainEmp.builder().isInsure(2).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, insureUser.getUserId()));
} }
} }
...@@ -1328,10 +1331,10 @@ public class InsureContorll { ...@@ -1328,10 +1331,10 @@ public class InsureContorll {
} catch (IOException e) { } catch (IOException e) {
log.error("导入保单:", e); log.error("导入保单:", e);
throw new CustomException("导入保单"); throw new CustomException("导入保单");
}finally { } finally {
if(xw!=null){ if (xw != null) {
try { try {
xw.close(); xw.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1343,7 +1346,7 @@ public class InsureContorll { ...@@ -1343,7 +1346,7 @@ public class InsureContorll {
@PostMapping(value = "/importUserPolicy") @PostMapping(value = "/importUserPolicy")
@ApiOperation(value = "15.导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户") @ApiOperation(value = "15.导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("orgCode") Integer orgCode) { public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("orgCode") Integer orgCode, @RequestParam("productId") Integer productId) {
Date now = new Date(); Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
/*当前年月*/ /*当前年月*/
...@@ -1353,10 +1356,16 @@ public class InsureContorll { ...@@ -1353,10 +1356,16 @@ public class InsureContorll {
if (orgCode == null) { if (orgCode == null) {
return ResultUtil.error("企业不存在"); return ResultUtil.error("企业不存在");
} }
if (productId == null) {
return ResultUtil.error("产品不存在");
}
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(orgCode).build().selectById(); QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(orgCode).build().selectById();
if (qyzxEntInfoM == null) { if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在"); return ResultUtil.error("企业不存在");
} }
InsureProduct insureProduct = InsureProduct.builder().id(productId).build().selectById();
List<InsureProductPlan> insureProductPlans = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda()
.eq(InsureProductPlan::getProductId, insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag, 0));
XSSFWorkbook xw = null; XSSFWorkbook xw = null;
try { try {
Map<String, String> map = Maps.newHashMap(); Map<String, String> map = Maps.newHashMap();
...@@ -1397,19 +1406,14 @@ public class InsureContorll { ...@@ -1397,19 +1406,14 @@ public class InsureContorll {
user.setInsuredNo(ExcelUtils.getString(cell)); user.setInsuredNo(ExcelUtils.getString(cell));
break; break;
case "基础计划": case "基础计划":
if (ExcelUtils.getString(cell).equals("30万意外/3万医疗/扩展24小时")) { if (Strings.isNullOrEmpty(ExcelUtils.getString(cell))) {
user.setBenefitBasicPlan("36968");
} else if (ExcelUtils.getString(cell).equals("50万意外/5万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36969");
} else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36970");
} else if (ExcelUtils.getString(cell).equals("80万意外/20万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36971");
} else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36972");
} else {
return ResultUtil.error("第" + i + "行第" + index + "基础计划不能为空"); return ResultUtil.error("第" + i + "行第" + index + "基础计划不能为空");
} }
InsureProductPlan insureProductPlan = insureProductPlans.stream().filter(v -> v.getName().equals(ExcelUtils.getString(cell).trim())).findFirst().orElse(null);
if (insureProductPlan == null) {
throw new CustomException("方案不存在");
}
user.setProductPlanId(insureProductPlan.getId());
break; break;
case "职业类型": case "职业类型":
if (ExcelUtils.getString(cell).equals("A类")) { if (ExcelUtils.getString(cell).equals("A类")) {
...@@ -1454,8 +1458,8 @@ public class InsureContorll { ...@@ -1454,8 +1458,8 @@ public class InsureContorll {
} catch (Exception e) { } catch (Exception e) {
log.error("导入被保人异常:", e); log.error("导入被保人异常:", e);
throw new CustomException("导入被保人异常"); throw new CustomException("导入被保人异常");
}finally { } finally {
if(xw!=null){ if (xw != null) {
try { try {
xw.close(); xw.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -1517,8 +1521,8 @@ public class InsureContorll { ...@@ -1517,8 +1521,8 @@ public class InsureContorll {
.returnMsg("请求保全支付").policyId(insurePolicy.getId()).build().insert(); .returnMsg("请求保全支付").policyId(insurePolicy.getId()).build().insert();
/*设置验签参数*/ /*设置验签参数*/
long timestamp = System.currentTimeMillis() / 1000; long timestamp = System.currentTimeMillis() / 1000;
String sign= DigestUtils.md5Hex(appidq + secretq + timestamp); String sign = DigestUtils.md5Hex(appidq + secretq + timestamp);
return ResultUtil.data(importPayInfo.get("pay_url").toString() + "&jump_url=" + base_api_url + "/callBack/policy/payStatus?policyId=" + insurePolicy.getId() + "&notify_url=" + base_api_url + "/callBack/policy/batchPayCallback&pid="+appidq+"&sign="+sign+"&timestamp="+timestamp); return ResultUtil.data(importPayInfo.get("pay_url").toString() + "&jump_url=" + base_api_url + "/callBack/policy/payStatus?policyId=" + insurePolicy.getId() + "&notify_url=" + base_api_url + "/callBack/policy/batchPayCallback&pid=" + appidq + "&sign=" + sign + "&timestamp=" + timestamp);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("重新发起支付异常:", e); log.error("重新发起支付异常:", e);
...@@ -1593,7 +1597,7 @@ public class InsureContorll { ...@@ -1593,7 +1597,7 @@ public class InsureContorll {
* *
* @return * @return
*/ */
public String creaXSSFWorkbook(List<PlansDto> plansList, String createDate,List<InsureProductPlan> priceList) throws Exception { public String creaXSSFWorkbook(List<PlansDto> plansList, String createDate, List<InsureProductPlan> priceList) throws Exception {
if (plansList.size() <= 0) { if (plansList.size() <= 0) {
return "error"; return "error";
...@@ -1604,7 +1608,7 @@ public class InsureContorll { ...@@ -1604,7 +1608,7 @@ public class InsureContorll {
plansList.forEach(p -> { plansList.forEach(p -> {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds()); List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
for (YgglMainEmp y : ygglMainEmpList) { for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), priceList.stream().filter(v->v.getId()==p.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getName(), createDate, "", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), getPlanType(p.getBenefitOccupationCategory())}; String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), priceList.stream().filter(v -> v.getId() == p.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getName(), createDate, "", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), getPlanType(p.getBenefitOccupationCategory())};
list.add(arr); list.add(arr);
} }
}); });
...@@ -1649,7 +1653,7 @@ public class InsureContorll { ...@@ -1649,7 +1653,7 @@ public class InsureContorll {
* @param ids * @param ids
* @return * @return
*/ */
public String creaXSSFWorkbook1(InsureDto insureDto,List<InsureProductPlan> priceList) throws Exception { public String creaXSSFWorkbook1(InsureDto insureDto, List<InsureProductPlan> priceList) throws Exception {
if (insureDto.getUserIds().length <= 0) { if (insureDto.getUserIds().length <= 0) {
return "error"; return "error";
} }
...@@ -1657,7 +1661,7 @@ public class InsureContorll { ...@@ -1657,7 +1661,7 @@ public class InsureContorll {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds()); List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
List list = Lists.newArrayList(); List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) { for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), priceList.stream().filter(v->v.getId()==insureDto.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getName(), insureDto.getPolicyDateStart(), "", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), getPlanType(insureDto.getBenefitOccupationCategory())}; String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), priceList.stream().filter(v -> v.getId() == insureDto.getBenefitBasicPlan()).collect(Collectors.toList()).get(0).getName(), insureDto.getPolicyDateStart(), "", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), getPlanType(insureDto.getBenefitOccupationCategory())};
list.add(arr); list.add(arr);
} }
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"}; String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
...@@ -1817,124 +1821,124 @@ public class InsureContorll { ...@@ -1817,124 +1821,124 @@ 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){ 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();
InsureProduct insureProduct = InsureProduct.builder().id(insurePolicy.getProductId()).build().selectById(); InsureProduct insureProduct = InsureProduct.builder().id(insurePolicy.getProductId()).build().selectById();
List<InsureProductPlan> priceList = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda() List<InsureProductPlan> priceList = InsureProductPlan.builder().build().selectList(new QueryWrapper<InsureProductPlan>().lambda()
.eq(InsureProductPlan::getProductId,insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag,0)); .eq(InsureProductPlan::getProductId, insureProduct.getId()).eq(InsureProductPlan::getDeleteFlag, 0));
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
XSSFWorkbook xw=null; XSSFWorkbook xw = null;
try { try {
xw = new XSSFWorkbook(file.getInputStream()); xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0); XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 13 //默认第一行为标题行,i = 13
XSSFRow titleRow = sheetAt.getRow(12); XSSFRow titleRow = sheetAt.getRow(12);
InsureUser originalUser; InsureUser originalUser;
InsureUser replaceUser; InsureUser replaceUser;
/*新被保人集合*/ /*新被保人集合*/
List<InsureUser> replaceList=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);
originalUser=InsureUser.builder().build(); originalUser = InsureUser.builder().build();
replaceUser=InsureUser.builder().build(); replaceUser = InsureUser.builder().build();
// 读取每一格内容 // 读取每一格内容
for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) { for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
XSSFCell titleCell = titleRow.getCell(index); XSSFCell titleCell = titleRow.getCell(index);
if(titleCell==null){ if (titleCell == null) {
continue; continue;
} }
XSSFCell cell = row.getCell(index); XSSFCell cell = row.getCell(index);
if (cell == null) { if (cell == null) {
continue; continue;
} else { } else {
cell.setCellType(CellType.STRING); cell.setCellType(CellType.STRING);
} }
if (cell.getStringCellValue().equals("")) { if (cell.getStringCellValue().equals("")) {
continue; continue;
} }
if(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))){ if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
continue; continue;
} }
switch (ExcelUtils.getString(titleCell)) { switch (ExcelUtils.getString(titleCell)) {
// case "ID":/*不重要*/ // case "ID":/*不重要*/
// break; // break;
case "name": case "name":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列被保人姓名不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列被保人姓名不能为空");
} }
originalUser.setInsuredEContact(ExcelUtils.getString(cell).trim()); originalUser.setInsuredEContact(ExcelUtils.getString(cell).trim());
break; break;
case "ID_type": case "ID_type":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列证件类型不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列证件类型不能为空");
} }
break; break;
case "ID_number": case "ID_number":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列证件号码不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列证件号码不能为空");
} }
originalUser.setInsuredNo(ExcelUtils.getString(cell)); originalUser.setInsuredNo(ExcelUtils.getString(cell));
break; break;
case "Update_date": case "Update_date":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列批改生效日不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列批改生效日不能为空");
} }
replaceUser.setPolicyDateStart(dtf3.parse(ExcelUtils.getString(cell)+" 00:00:00")); replaceUser.setPolicyDateStart(dtf3.parse(ExcelUtils.getString(cell) + " 00:00:00"));
break; break;
case "replace_name": case "replace_name":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列新保人员姓名不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列新保人员姓名不能为空");
} }
replaceUser.setInsuredEContact(ExcelUtils.getString(cell)); replaceUser.setInsuredEContact(ExcelUtils.getString(cell));
break; break;
case "replace_ID_type": case "replace_ID_type":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件类型不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件类型不能为空");
} }
break; break;
case "replace_ID_number": case "replace_ID_number":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) { if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件号不能为空"); return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件号不能为空");
} }
replaceUser.setInsuredNo(ExcelUtils.getString(cell)); replaceUser.setInsuredNo(ExcelUtils.getString(cell));
break; break;
case "Tricycle_frame_number": case "Tricycle_frame_number":
replaceUser.setTricycleFrameNumber(ExcelUtils.getString(cell)); replaceUser.setTricycleFrameNumber(ExcelUtils.getString(cell));
break; break;
case "benefit_occupation_category": case "benefit_occupation_category":
replaceUser.setBenefitOccupationCategory(ExcelUtils.getString(cell)); replaceUser.setBenefitOccupationCategory(ExcelUtils.getString(cell));
break; break;
default: default:
continue; continue;
}
} }
replaceUser.setOriginaUser(originalUser);
replaceList.add(replaceUser);
} }
replaceUser.setOriginaUser(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) { for (InsureUser insureUser : replaceList) {
/*获取原投保人*/ /*获取原投保人*/
InsureUser getInsureUser = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda() InsureUser getInsureUser = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda()
.eq(InsureUser::getInsuredEContact,insureUser.getOriginaUser().getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getOriginaUser().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::getInsureStatus, 1).eq(InsureUser::getStatus, 1).eq(InsureUser::getPolicyId, policyId));
if(getInsureUser==null){ if (getInsureUser == null) {
return ResultUtil.error(insureUser.getInsuredEContact()+"未投保"); return ResultUtil.error(insureUser.getInsuredEContact() + "未投保");
} }
/*设置保单套餐*/ /*设置保单套餐*/
insureUser.setOriginaUser(getInsureUser); insureUser.setOriginaUser(getInsureUser);
insureUser.setBenefitBasicPlan(getInsureUser.getBenefitBasicPlan()); insureUser.setProductPlanId(getInsureUser.getProductPlanId());
insureUser.setBenefitOccupationCategory(getInsureUser.getBenefitOccupationCategory()); insureUser.setBenefitOccupationCategory(getInsureUser.getBenefitOccupationCategory());
originaInuserUserList.add(getInsureUser); originaInuserUserList.add(getInsureUser);
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda() YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getName,insureUser.getInsuredEContact()) .eq(YgglMainEmp::getName, insureUser.getInsuredEContact())
.eq(YgglMainEmp::getZjNum,insureUser.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();
ygglMainEmp = new YgglMainEmp(); ygglMainEmp = new YgglMainEmp();
...@@ -1968,7 +1972,7 @@ public class InsureContorll { ...@@ -1968,7 +1972,7 @@ public class InsureContorll {
Object o = dataMap.get("data"); Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o)); Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString(); url = map.get("file_url").toString();
if(StringUtils.isNullOrEmpty(url)||url=="error"){ if (StringUtils.isNullOrEmpty(url) || url == "error") {
throw new CustomException("上传文件路径异常"); throw new CustomException("上传文件路径异常");
} }
} }
...@@ -2005,7 +2009,7 @@ public class InsureContorll { ...@@ -2005,7 +2009,7 @@ public class InsureContorll {
} else { } else {
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById(); QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(insurePolicy.getOrgCode()).build().selectById();
replaceList.forEach(y -> { replaceList.forEach(y -> {
Double price = priceList.stream().filter(v->v.getId()==y.getProductPlanId()).collect(Collectors.toList()).get(0).getPrice(); Double price = priceList.stream().filter(v -> v.getId() == y.getProductPlanId()).collect(Collectors.toList()).get(0).getPrice();
InsureUser.builder() InsureUser.builder()
.transId("RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now)) .transId("RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.insuredName(qyzxEntInfoM.getName()) .insuredName(qyzxEntInfoM.getName())
...@@ -2037,10 +2041,10 @@ public class InsureContorll { ...@@ -2037,10 +2041,10 @@ public class InsureContorll {
} }
return ResultUtil.error("导入失败"); return ResultUtil.error("导入失败");
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new CustomException("导入异常"); throw new CustomException("导入异常");
}finally { } finally {
try { try {
bos.close(); bos.close();
} catch (IOException e) { } catch (IOException e) {
......
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