| | |
| | | package org.springblade.modules.equipage.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.common.utils.arg; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | 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.FTP.FtpUtil; |
| | | import org.springblade.modules.equipage.entity.Car; |
| | | import org.springblade.modules.equipage.excel.CarExcel; |
| | | import org.springblade.modules.equipage.excel.CarImporter; |
| | | import org.springblade.modules.equipage.service.CarService; |
| | | import org.springblade.modules.equipage.vo.CarVo; |
| | | 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.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | return R.data(detail); |
| | | } |
| | | |
| | | /** |
| | | * 导入车辆信息, excel |
| | | */ |
| | | @PostMapping("import-car") |
| | | public R importCar(MultipartFile file, Integer isCovered,String deptId) { |
| | | CarImporter carImporter = new CarImporter(carService, false,deptId); |
| | | ExcelUtil.save(file, carImporter, CarExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 车辆导出模板 |
| | | */ |
| | | @GetMapping("export-template-car") |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportSecurity(HttpServletResponse response) throws IOException { |
| | | List<CarExcel> list = new ArrayList<>(); |
| | | CarExcel carExcel1 = new CarExcel(); |
| | | carExcel1.setDeptId("xxx保安公司"); |
| | | carExcel1.setBrand("****"); |
| | | carExcel1.setCarNumber("赣A415225"); |
| | | carExcel1.setMode("X54512545"); |
| | | carExcel1.setPersonInCharge("张三"); |
| | | carExcel1.setUmweltsatz("国IV"); |
| | | list.add(carExcel1); |
| | | 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(), CarExcel.class).sheet("车辆数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list); |
| | | } catch (Throwable var6) { |
| | | throw var6; |
| | | } |
| | | } |
| | | |
| | | } |