Commit 321794e9 by 翁国栋 Committed by 284718418@qq.com

8小时后台--

投保人员,导出调整
parent 1b5d1a58
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("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