|
|
@ -10,6 +10,7 @@ import com.epmet.commons.tools.utils.FileUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.dto.result.LingShanSpecialCrowdListResultDTO; |
|
|
|
import com.epmet.enums.LingShanSpecialCrowdTypeEnums; |
|
|
|
import com.epmet.excel.data.*; |
|
|
|
import com.epmet.service.LingShanSpecialCrowdService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -19,8 +20,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.util.Date; |
|
|
@ -42,6 +47,41 @@ public class LingShanSpecialCrowdController { |
|
|
|
@Autowired |
|
|
|
private LingShanSpecialCrowdService lingShanSpecialCrowdService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 下载导入模板 |
|
|
|
* @param specialType: |
|
|
|
* @return |
|
|
|
* @author: WangXianZhang |
|
|
|
* @date: 2023/4/21 10:16 AM |
|
|
|
*/ |
|
|
|
@GetMapping("downloadTemplate") |
|
|
|
public void downloadTemplate(@RequestParam("specialType") String specialType, HttpServletResponse response) { |
|
|
|
InputStream is = null; |
|
|
|
|
|
|
|
LingShanSpecialCrowdTypeEnums st = LingShanSpecialCrowdTypeEnums.getByType(specialType); |
|
|
|
if (st == null) { |
|
|
|
log.error("【灵山街道-下载特殊人群导入模板】传入的特殊人群类型错误:{}", specialType); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
try (ServletOutputStream os = response.getOutputStream()) { |
|
|
|
is = this.getClass().getClassLoader().getResourceAsStream("excel/lingshan/special_crowd_" + specialType + "_import.xlsx"); |
|
|
|
|
|
|
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
|
|
|
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(st.getName(), "UTF-8")); |
|
|
|
|
|
|
|
IOUtils.copy(is, os); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} finally { |
|
|
|
org.apache.poi.util.IOUtils.closeQuietly(is); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 特殊人群导入 |
|
|
|
* @param file: |
|
|
|