| | |
| | | package org.springblade.modules.securitypaper.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.codec.Charsets; |
| | | import org.springblade.common.excel.RowWriteHandler; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.securitypaper.entity.SecurityPaper; |
| | | import org.springblade.modules.securitypaper.excel.PaperExcel; |
| | | import org.springblade.modules.securitypaper.excel.PaperImporter; |
| | | import org.springblade.modules.securitypaper.excel.SecurityPaperExcel; |
| | | import org.springblade.modules.securitypaper.excel.SecurityPaperImporter; |
| | | import org.springblade.modules.securitypaper.service.SecurityPaperService; |
| | |
| | | import org.springblade.modules.system.excel.SecurityImporter; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | |
| | | |
| | | /** |
| | | * 导入保安员证数据 |
| | | * 导入保安员证数据(需用户编号,无效保安员身份证号码) |
| | | */ |
| | | @PostMapping("import-security-paper") |
| | | public R importSecurityPaper(MultipartFile file, Integer isCovered, String deptId) { |
| | |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导入保安员证数据(需身份证号码,无需用户编号) |
| | | */ |
| | | @PostMapping("import-paper") |
| | | public R importPaper(MultipartFile file, Integer isCovered) { |
| | | PaperImporter paperImporter = new PaperImporter(securityPaperService, false); |
| | | ExcelUtil.save(file, paperImporter, PaperExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导出模板 |
| | | */ |
| | | @GetMapping("export-template-security-paper") |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportSecurity(HttpServletResponse response) throws IOException { |
| | | List<SecurityPaperExcel> list = new ArrayList<>(); |
| | | SecurityPaperExcel securityExcel = new SecurityPaperExcel(); |
| | | securityExcel.setId("12124121245121"); |
| | | securityExcel.setRealName("张三"); |
| | | // securityExcel.setPhone("12345678901"); |
| | | // securityExcel.setCardid("360XXX19XXXXXX****"); |
| | | // securityExcel.setRegistered("江西省南昌市******"); |
| | | list.add(securityExcel); |
| | | |
| | | SecurityPaperExcel securityExcel1 = new SecurityPaperExcel(); |
| | | securityExcel.setId("12124121245121"); |
| | | securityExcel1.setRealName("李四"); |
| | | // securityExcel1.setPhone("12345678901"); |
| | | // securityExcel1.setCardid("360XXX19XXXXXX****"); |
| | | // securityExcel1.setRegistered("江西省南昌市******"); |
| | | list.add(securityExcel1); |
| | | String fileName = null; |
| | | try { |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name()); |
| | | fileName = URLEncoder.encode("保安员导入数据模板-制证" + DateUtil.time(), Charsets.UTF_8.name()); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | //修改单元格格式为文本格式 |
| | | EasyExcel.write(response.getOutputStream(), SecurityPaperExcel.class).sheet("保安员数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list); |
| | | } catch (Throwable var6) { |
| | | throw var6; |
| | | } |
| | | } |
| | | |
| | | } |