Commit 12265316 by 翁国栋

8小时后台--

投保人员,导出调整
parent 8c92b3d6
...@@ -25,6 +25,7 @@ import cn.timer.api.utils.*; ...@@ -25,6 +25,7 @@ import cn.timer.api.utils.*;
import com.alibaba.druid.util.Base64; import com.alibaba.druid.util.Base64;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists; import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
...@@ -807,8 +808,9 @@ public class InsureContorll { ...@@ -807,8 +808,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;
try { try {
XSSFWorkbook 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);
...@@ -899,6 +901,17 @@ public class InsureContorll { ...@@ -899,6 +901,17 @@ public class InsureContorll {
} catch (IOException e) { } catch (IOException e) {
log.error("一键校验异常:", e); log.error("一键校验异常:", e);
throw new CustomException("一键校验异常"); throw new CustomException("一键校验异常");
}catch (Exception e){
new CustomException("导入用户异常");
}finally {
if(xw!=null){
try {
xw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList()); List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList());
if (message.size() > 0) { if (message.size() > 0) {
...@@ -922,8 +935,9 @@ public class InsureContorll { ...@@ -922,8 +935,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;
try { try {
XSSFWorkbook 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);
...@@ -1009,6 +1023,14 @@ public class InsureContorll { ...@@ -1009,6 +1023,14 @@ public class InsureContorll {
} catch (IOException e) { } catch (IOException e) {
log.error("导入用户:", e); log.error("导入用户:", e);
throw new CustomException("导入用户"); throw new CustomException("导入用户");
}finally {
if(xw!=null){
try {
xw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList()); List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList());
if (message.size() > 0) { if (message.size() > 0) {
...@@ -1031,8 +1053,9 @@ public class InsureContorll { ...@@ -1031,8 +1053,9 @@ public class InsureContorll {
if (insureProduct == null) { if (insureProduct == null) {
return ResultUtil.error("产品不存在"); return ResultUtil.error("产品不存在");
} }
XSSFWorkbook xw=null;
try { try {
XSSFWorkbook 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);
...@@ -1156,7 +1179,7 @@ public class InsureContorll { ...@@ -1156,7 +1179,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.getName())){ if(!dataMap.get("corporate_applicant_name").equals(company.getAttestName())){
return ResultUtil.error("导入的保单投保人和企业投保人不一样"); return ResultUtil.error("导入的保单投保人和企业投保人不一样");
} }
policy.setProductId(insureProduct.getId()); policy.setProductId(insureProduct.getId());
...@@ -1245,6 +1268,14 @@ public class InsureContorll { ...@@ -1245,6 +1268,14 @@ public class InsureContorll {
} catch (IOException e) { } catch (IOException e) {
log.error("导入保单:", e); log.error("导入保单:", e);
throw new CustomException("导入保单"); throw new CustomException("导入保单");
}finally {
if(xw!=null){
try {
xw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
return ResultUtil.data("成功导入"); return ResultUtil.data("成功导入");
} }
...@@ -1266,8 +1297,8 @@ public class InsureContorll { ...@@ -1266,8 +1297,8 @@ public class InsureContorll {
if (qyzxEntInfoM == null) { if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在"); return ResultUtil.error("企业不存在");
} }
try {
XSSFWorkbook xw = null; XSSFWorkbook xw = null;
try {
Map<String, String> map = Maps.newHashMap(); Map<String, String> map = Maps.newHashMap();
try { try {
xw = new XSSFWorkbook(file.getInputStream()); xw = new XSSFWorkbook(file.getInputStream());
...@@ -1312,7 +1343,7 @@ public class InsureContorll { ...@@ -1312,7 +1343,7 @@ public class InsureContorll {
user.setBenefitBasicPlan("36969"); user.setBenefitBasicPlan("36969");
} else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) { } else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36970"); user.setBenefitBasicPlan("36970");
} else if (ExcelUtils.getString(cell).equals("80万雇主/20万医疗/扩展24小时")) { } else if (ExcelUtils.getString(cell).equals("80万意外/20万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36971"); user.setBenefitBasicPlan("36971");
} else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) { } else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36972"); user.setBenefitBasicPlan("36972");
...@@ -1363,6 +1394,14 @@ public class InsureContorll { ...@@ -1363,6 +1394,14 @@ public class InsureContorll {
} catch (Exception e) { } catch (Exception e) {
log.error("导入被保人异常:", e); log.error("导入被保人异常:", e);
throw new CustomException("导入被保人异常"); throw new CustomException("导入被保人异常");
}finally {
if(xw!=null){
try {
xw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
} }
......
package cn.timer.api.controller.insure; package cn.timer.api.controller.insure;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
...@@ -31,6 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -31,6 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* 被保人 * 被保人
...@@ -97,14 +106,16 @@ public class InsureUserController{ ...@@ -97,14 +106,16 @@ public class InsureUserController{
return ResultUtil.data(userList); return ResultUtil.data(userList);
} }
@PostMapping(value = "/exportUserList")
@GetMapping(value = "/exportUserList")
@ApiOperation(value = "导出列表", httpMethod = "GET", notes = "导出列表") @ApiOperation(value = "导出列表", httpMethod = "GET", notes = "导出列表")
public void exportUserList(@RequestParam("policyId") String policyId, public void exportUserList(@RequestParam("policyId") String policyId,
@RequestParam("status") String status, @RequestParam("status") String status,
@RequestParam("name") String name, @RequestParam("name") String name,
@RequestParam("policyDateStart") String policyDateStart, @RequestParam("policyDateStart") String policyDateStart,
@RequestParam("planId") String planId, @RequestParam("planId") String planId,
@RequestParam("categoryId") String categoryId){ @RequestParam("categoryId") String categoryId, HttpServletRequest request, HttpServletResponse resp){
LocalDate localDate = LocalDate.now();
PolicyDto policyDto = new PolicyDto(); PolicyDto policyDto = new PolicyDto();
policyDto.setId(Integer.parseInt(policyId)); policyDto.setId(Integer.parseInt(policyId));
policyDto.setStatus(status); policyDto.setStatus(status);
...@@ -112,9 +123,34 @@ public class InsureUserController{ ...@@ -112,9 +123,34 @@ public class InsureUserController{
policyDto.setPolicyDateStart(policyDateStart); policyDto.setPolicyDateStart(policyDateStart);
policyDto.setPlanId(planId); policyDto.setPlanId(planId);
policyDto.setCategoryId(categoryId); policyDto.setCategoryId(categoryId);
List<PolicyDto> list = insureUserMapper.selectPolicyList(policyDto); Page page=new Page();
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"}; page.setOffset(null);
page.setTotalPage(null);
policyDto.setPage(page);
List<PolicyDto> userList = insureUserMapper.selectPolicyList(policyDto);
String[] rowName = new String[]{"编号", "姓名", "证件类型", "证件号", "保单号", "状态", "计划", "保险生效时间", "保险失效时间"};
List<Object[]> list = null;
// for () // for ()
// XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel("导出人员清单.xlsx", rowName, list); // XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel("导出人员清单.xlsx", rowName, list);
OutputStream os = null;
try {
resp.setContentType("application/octet-stream");
resp.setHeader("content-disposition", "attachment; filename=" + URLEncoder.encode(localDate+"_"+list.size()+"名人员清单.xlsx", "UTF-8"));
resp.setCharacterEncoding("UTF-8");
os = resp.getOutputStream();
XSSFWorkbook workbook= ExcelUtils.exportExcel(localDate+"_"+list.size()+"投保人列表导出.xlsx",rowName, Collections.singletonList(list.stream().toArray()));
workbook.write(os);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
} }
...@@ -47,4 +47,5 @@ public class PolicyDto { ...@@ -47,4 +47,5 @@ public class PolicyDto {
private String monthD; private String monthD;
private String userName; private String userName;
private String companyName; private String companyName;
private boolean isAll = false;
} }
...@@ -338,7 +338,7 @@ ...@@ -338,7 +338,7 @@
</where> </where>
order by iu.create_time desc order by iu.create_time desc
<if test="policyDto.page.offset != null and policyDto.page.totalPage !=null"> <if test="!policyDto.isAll">
LIMIT #{policyDto.page.offset},#{policyDto.page.totalPage} LIMIT #{policyDto.page.offset},#{policyDto.page.totalPage}
</if> </if>
......
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