feat: 三标导入excel文件自解密
This commit is contained in:
+57
-27
@@ -15,6 +15,7 @@ import com.jero.common.constant.enums.LanguageEnum;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.IntekeyUtils;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.common.util.MinioUtil;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -166,17 +168,33 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
@Resource
|
||||
private PartNameService partNameService;
|
||||
|
||||
@Resource
|
||||
private ILawsEnterpriseStandardService esService;
|
||||
|
||||
@Resource
|
||||
private IProcessFbStandardConsultationService processFbStandardConsultationService;
|
||||
|
||||
@Resource
|
||||
private ILawsDomesticStandardService gbService;
|
||||
public static boolean ENCRYPT_ENABLE;
|
||||
public static String DECRYPT_URL;
|
||||
public static String DECRYPT_APP_CODE;
|
||||
public static String DECRYPT_SECRET_KEY;
|
||||
|
||||
@Resource
|
||||
private ILawsOverseasStandardService fbService;
|
||||
@Value("${download.enable}")
|
||||
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
|
||||
@@ -687,7 +705,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
String id = executeInsertByModel(module);
|
||||
// 更新语句
|
||||
UpdateWrapper updateWrapper = new UpdateWrapper();
|
||||
updateWrapper.eq("id",id);
|
||||
updateWrapper.eq("id", id);
|
||||
// 拼接要添加的数据
|
||||
for (Map.Entry<String, Object> entryMap : parameterMap.entrySet()) {
|
||||
String key = entryMap.getKey();
|
||||
@@ -697,13 +715,13 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
// 如果value不为null和"",则拼接查询条件
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
jointInsertFieldAndValue(fieldList, key, value, id, standardNumber,updateWrapper);
|
||||
jointInsertFieldAndValue(fieldList, key, value, id, standardNumber, updateWrapper);
|
||||
}
|
||||
}
|
||||
// 操作数据库进行新增数据
|
||||
//lawsCommonMapper.commonAdd(tableName, fieldsBuilder.toString(), valuesBuilder.toString());
|
||||
//根据类型更新数据
|
||||
executeUpdateWrapperByModel(module,updateWrapper);
|
||||
executeUpdateWrapperByModel(module, updateWrapper);
|
||||
|
||||
// 对标准体系做处理
|
||||
lawsNodeRelationService.addRelation(standardSystem, standardNumber, id);
|
||||
@@ -849,13 +867,13 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 更新语句
|
||||
StringBuilder updateBuilder = new StringBuilder();
|
||||
UpdateWrapper updateWrapper = new UpdateWrapper();
|
||||
updateWrapper.eq("id",id);
|
||||
updateWrapper.eq("id", id);
|
||||
|
||||
// 拼接默认的更新语句
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
updateWrapper.set("update_time",date);
|
||||
updateWrapper.set("update_By",sysUser.getUsername());
|
||||
updateWrapper.set("update_time", date);
|
||||
updateWrapper.set("update_By", sysUser.getUsername());
|
||||
// 封装参数的更新语句
|
||||
for (Map.Entry<String, Object> entryMap : parameterMap.entrySet()) {
|
||||
String key = entryMap.getKey();
|
||||
@@ -873,7 +891,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 操作数据库进行更新数据
|
||||
//lawsDomesticStandardService.update(updateWrapper);
|
||||
//根据类型更新数据
|
||||
executeUpdateWrapperByModel(module,updateWrapper);
|
||||
executeUpdateWrapperByModel(module, updateWrapper);
|
||||
//lawsCommonMapper.commonEdit(tableName, updateWrapper, id);
|
||||
// 如果修改了内容
|
||||
String content = recordBuffer.toString();
|
||||
@@ -903,31 +921,31 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
|
||||
private void executeUpdateWrapperByModel(String module, UpdateWrapper updateWrapper) {
|
||||
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(module)){
|
||||
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(module)) {
|
||||
lawsDomesticStandardService.update(updateWrapper);
|
||||
}else if (TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(module)){
|
||||
} else if (TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(module)) {
|
||||
lawsOverseasStandardService.update(updateWrapper);
|
||||
}else if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(module)){
|
||||
} else if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(module)) {
|
||||
lawsEnterpriseStandardService.update(updateWrapper);
|
||||
}else if (TableNameEnum.DOCUMENT_SPLIT.getValue().equals(module)){
|
||||
documentSplitMapper.update(null,updateWrapper);
|
||||
} else if (TableNameEnum.DOCUMENT_SPLIT.getValue().equals(module)) {
|
||||
documentSplitMapper.update(null, updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
private String executeInsertByModel(String module) {
|
||||
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(module)){
|
||||
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(module)) {
|
||||
LawsDomesticStandard lawsDomesticStandard = new LawsDomesticStandard();
|
||||
lawsDomesticStandardService.save(lawsDomesticStandard);
|
||||
return lawsDomesticStandard.getId();
|
||||
}else if (TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(module)){
|
||||
} else if (TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(module)) {
|
||||
LawsOverseasStandard lawsOverseasStandard = new LawsOverseasStandard();
|
||||
lawsOverseasStandardService.save(lawsOverseasStandard);
|
||||
return lawsOverseasStandard.getId();
|
||||
}else if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(module)){
|
||||
} else if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(module)) {
|
||||
LawsEnterpriseStandard lawsEnterpriseStandard = new LawsEnterpriseStandard();
|
||||
lawsEnterpriseStandardService.save(lawsEnterpriseStandard);
|
||||
return lawsEnterpriseStandard.getId();
|
||||
}else {
|
||||
} else {
|
||||
LawsDocumentSplit lawsDocumentSplit = new LawsDocumentSplit();
|
||||
documentSplitMapper.insert(lawsDocumentSplit);
|
||||
return lawsDocumentSplit.getId();
|
||||
@@ -1721,7 +1739,19 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 遍历saveDirectory下的所有文件
|
||||
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
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
// 验证前三行是否有数据
|
||||
@@ -1810,7 +1840,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
for (LawsTag lawsTag : fieldList) {
|
||||
if (key.equals(lawsTag.getDbFieldName())) {
|
||||
jointInsertFieldSetValue(lawsTag, key, value, id, standardNumber,updateWrapper);
|
||||
jointInsertFieldSetValue(lawsTag, key, value, id, standardNumber, updateWrapper);
|
||||
}
|
||||
}
|
||||
// 如果是标准编号
|
||||
@@ -1840,7 +1870,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 拼接新增字段
|
||||
// 对数据值做格式处理
|
||||
String setValue = setValue(lawsTag.getFieldShowType(), value);
|
||||
updateWrapper.set(key,setValue);
|
||||
updateWrapper.set(key, setValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1941,7 +1971,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
} else {
|
||||
// 做格式处理
|
||||
String setValue = setValue(lawsTag.getFieldShowType(), value);
|
||||
updateWrapper.set(key , setValue);
|
||||
updateWrapper.set(key, setValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user