Commit 12265316 by 翁国栋

8小时后台--

投保人员,导出调整
parent 8c92b3d6
......@@ -25,6 +25,7 @@ import cn.timer.api.utils.*;
import com.alibaba.druid.util.Base64;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
......@@ -807,8 +808,9 @@ public class InsureContorll {
List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList = Lists.newArrayList();
List<YgglMainEmp> allList = Lists.newArrayList();
XSSFWorkbook xw=null;
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0);
......@@ -899,6 +901,17 @@ public class InsureContorll {
} catch (IOException e) {
log.error("一键校验异常:", e);
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());
if (message.size() > 0) {
......@@ -922,8 +935,9 @@ public class InsureContorll {
List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList = Lists.newArrayList();
List<YgglMainEmp> allList = Lists.newArrayList();
XSSFWorkbook xw=null;
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0);
......@@ -1009,6 +1023,14 @@ public class InsureContorll {
} catch (IOException e) {
log.error("导入用户:", e);
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());
if (message.size() > 0) {
......@@ -1031,8 +1053,9 @@ public class InsureContorll {
if (insureProduct == null) {
return ResultUtil.error("产品不存在");
}
XSSFWorkbook xw=null;
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0);
......@@ -1156,7 +1179,7 @@ public class InsureContorll {
if (!dataMap.get("product_code").equals(insureProduct.getProductCodeId())) {
return ResultUtil.error("导入的保单产品和选择的保单产品不一致");
}
if(!dataMap.get("corporate_applicant_name").equals(company.getName())){
if(!dataMap.get("corporate_applicant_name").equals(company.getAttestName())){
return ResultUtil.error("导入的保单投保人和企业投保人不一样");
}
policy.setProductId(insureProduct.getId());
......@@ -1245,6 +1268,14 @@ public class InsureContorll {
} catch (IOException e) {
log.error("导入保单:", e);
throw new CustomException("导入保单");
}finally {
if(xw!=null){
try {
xw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return ResultUtil.data("成功导入");
}
......@@ -1266,8 +1297,8 @@ public class InsureContorll {
if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在");
}
XSSFWorkbook xw = null;
try {
XSSFWorkbook xw = null;
Map<String, String> map = Maps.newHashMap();
try {
xw = new XSSFWorkbook(file.getInputStream());
......@@ -1312,7 +1343,7 @@ public class InsureContorll {
user.setBenefitBasicPlan("36969");
} else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36970");
} else if (ExcelUtils.getString(cell).equals("80万雇主/20万医疗/扩展24小时")) {
} else if (ExcelUtils.getString(cell).equals("80万意外/20万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36971");
} else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36972");
......@@ -1363,6 +1394,14 @@ public class InsureContorll {
} catch (Exception e) {
log.error("导入被保人异常:", e);
throw new CustomException("导入被保人异常");
}finally {
if(xw!=null){
try {
xw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......
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.Map;
import java.util.Optional;
......@@ -31,6 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 被保人
......@@ -97,14 +106,16 @@ public class InsureUserController{
return ResultUtil.data(userList);
}
@PostMapping(value = "/exportUserList")
@GetMapping(value = "/exportUserList")
@ApiOperation(value = "导出列表", httpMethod = "GET", notes = "导出列表")
public void exportUserList(@RequestParam("policyId") String policyId,
@RequestParam("status") String status,
@RequestParam("name") String name,
@RequestParam("policyDateStart") String policyDateStart,
@RequestParam("planId") String planId,
@RequestParam("categoryId") String categoryId){
@RequestParam("status") String status,
@RequestParam("name") String name,
@RequestParam("policyDateStart") String policyDateStart,
@RequestParam("planId") String planId,
@RequestParam("categoryId") String categoryId, HttpServletRequest request, HttpServletResponse resp){
LocalDate localDate = LocalDate.now();
PolicyDto policyDto = new PolicyDto();
policyDto.setId(Integer.parseInt(policyId));
policyDto.setStatus(status);
......@@ -112,9 +123,34 @@ public class InsureUserController{
policyDto.setPolicyDateStart(policyDateStart);
policyDto.setPlanId(planId);
policyDto.setCategoryId(categoryId);
List<PolicyDto> list = insureUserMapper.selectPolicyList(policyDto);
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
Page page=new Page();
page.setOffset(null);
page.setTotalPage(null);
policyDto.setPage(page);
List<PolicyDto> userList = insureUserMapper.selectPolicyList(policyDto);
String[] rowName = new String[]{"编号", "姓名", "证件类型", "证件号", "保单号", "状态", "计划", "保险生效时间", "保险失效时间"};
List<Object[]> list = null;
// for ()
// 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 {
private String monthD;
private String userName;
private String companyName;
private boolean isAll = false;
}
......@@ -338,7 +338,7 @@
</where>
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}
</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