feat: 三标导入excel文件自解密

This commit is contained in:
2024-04-01 16:59:20 +08:00
parent 2a6af0c082
commit 0c82232972
@@ -15,6 +15,7 @@ import com.jero.common.constant.enums.LanguageEnum;
import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.constant.enums.YesOrNoEnum;
import com.jero.common.exception.JeroBootException; import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser; import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.IntekeyUtils;
import com.jero.common.util.MessageUtils; import com.jero.common.util.MessageUtils;
import com.jero.common.util.MinioUtil; import com.jero.common.util.MinioUtil;
import com.jero.modules.activiti.process.common.enums.StandardStateEnum; import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
@@ -76,6 +77,7 @@ import org.apache.shiro.SecurityUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -166,17 +168,33 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
@Resource @Resource
private PartNameService partNameService; private PartNameService partNameService;
@Resource
private ILawsEnterpriseStandardService esService;
@Resource @Resource
private IProcessFbStandardConsultationService processFbStandardConsultationService; private IProcessFbStandardConsultationService processFbStandardConsultationService;
@Resource public static boolean ENCRYPT_ENABLE;
private ILawsDomesticStandardService gbService; public static String DECRYPT_URL;
public static String DECRYPT_APP_CODE;
public static String DECRYPT_SECRET_KEY;
@Resource @Value("${download.enable}")
private ILawsOverseasStandardService fbService; public void setEnable(boolean enable) {
ENCRYPT_ENABLE = enable;
}
@Value("${download.decrypt.url}")
public void setDecryptUrl(String decryptUrl) {
DECRYPT_URL = decryptUrl;
}
@Value("${download.decrypt.app_code}")
public void setDecryptAppCode(String decryptAppCode) {
DECRYPT_APP_CODE = decryptAppCode;
}
@Value("${download.decrypt.secret_key}")
public void setDecryptSecretKey(String decryptSecretKey) {
DECRYPT_SECRET_KEY = decryptSecretKey;
}
/** /**
* @Author: liao * @Author: liao
@@ -1721,7 +1739,19 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 遍历saveDirectory下的所有文件 // 遍历saveDirectory下的所有文件
populateFileMap(saveDirectory, saveDirectory, fileMap); populateFileMap(saveDirectory, saveDirectory, fileMap);
try (Workbook workbook = new XSSFWorkbook(Files.newInputStream(excelfilelist.get(0).toPath()))) { // 将excel文件解密
InputStream inputStream = null;
if (ENCRYPT_ENABLE) {
inputStream = IntekeyUtils.decryptFile(DECRYPT_URL, DECRYPT_APP_CODE, DECRYPT_SECRET_KEY, null,
new MockMultipartFile(
excelfilelist.get(0).getName(),
excelfilelist.get(0).getName(),
(String) null,
Files.newInputStream(excelfilelist.get(0).toPath())));
} else {
inputStream = Files.newInputStream(excelfilelist.get(0).toPath());
}
try (Workbook workbook = new XSSFWorkbook(inputStream)) {
// 检测是否是空Excel // 检测是否是空Excel
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
// 验证前三行是否有数据 // 验证前三行是否有数据