Commit 6369d972 by 翁国栋

导入方案处理

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