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

8小时后台--

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