feat(sis): 解压指定编码GBK
This commit is contained in:
parent
9afeed3108
commit
6c57942886
@ -3,6 +3,7 @@ package org.dromara.property.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
@ -12,6 +13,7 @@ import org.dromara.property.domain.vo.ResidentPersonImportVo;
|
||||
import org.dromara.property.listener.ResidentPersonImportListener;
|
||||
import org.dromara.property.utils.UploadFaceUtil;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@ -34,7 +36,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
* 前端访问路由地址为:/property/person
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-19
|
||||
* @since 2025-06-19
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@ -128,6 +130,16 @@ public class ResidentPersonController extends BaseController {
|
||||
return R.ok(result.getAnalysis());
|
||||
}
|
||||
|
||||
@Async
|
||||
public void asyncImportExcel(String tokenValue, MultipartFile file, Boolean updateSupport, Long unitId) {
|
||||
try {
|
||||
StpUtil.setTokenValueToStorage(tokenValue);
|
||||
ExcelResult<ResidentPersonImportVo> result = ExcelUtil.importExcel(file.getInputStream(), ResidentPersonImportVo.class, new ResidentPersonImportListener(updateSupport, unitId));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入模板
|
||||
*/
|
||||
@ -139,7 +151,7 @@ public class ResidentPersonController extends BaseController {
|
||||
/**
|
||||
* 导入人脸数据
|
||||
*
|
||||
* @param file 导入文件
|
||||
* @param file 导入文件
|
||||
* @param unitId 单位ID
|
||||
*/
|
||||
@PostMapping(value = "/importFace", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
|
@ -14,7 +14,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
@ -58,7 +58,7 @@ public class UploadFaceUtil {
|
||||
// 重置统计信息
|
||||
resetStats();
|
||||
|
||||
try (ZipInputStream zis = new ZipInputStream(zipFile.getInputStream(), StandardCharsets.UTF_8)) {
|
||||
try (ZipInputStream zis = new ZipInputStream(zipFile.getInputStream(), Charset.forName("GBK"))) {
|
||||
ZipEntry entry;
|
||||
byte[] buffer = new byte[8192]; // 8KB缓冲区
|
||||
long totalExtractedSize = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user