fix: 企标导入优化

This commit is contained in:
2024-08-13 11:15:56 +08:00
parent 79ad725c01
commit dee7060988
2 changed files with 18 additions and 6 deletions
@@ -1843,21 +1843,21 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
String excelName = excelfilelist.get(0).getName();
if (tableName.equals(TableNameEnum.ENTERPRISE_STANDARDS.getTableName())) {
// 检查Excel的文件名
if (!excelName.equals("企业标准导入模板.xls")) {
if (!excelName.contains("企业标准导入模板.xls")) {
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
}
}
if (tableName.equals(TableNameEnum.DOMESTIC_REGULATIONS.getTableName())) {
// 检查Excel的文件名
if (!excelName.equals("国内标准导入模板.xls")) {
if (!excelName.contains("国内标准导入模板.xls")) {
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
}
}
if (tableName.equals(TableNameEnum.FOREIGN_REGULATIONS.getTableName())) {
// 检查Excel的文件名
if (!excelName.equals("海外标准导入模板.xls")) {
if (!excelName.contains("海外标准导入模板.xls")) {
FileUnZip.deleteDir(saveDirectory);
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
}
@@ -2884,6 +2884,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
.filter(lawsTag -> !lawsTag.getDbFieldName().equals(FieldCommon.YEAR_NUMBER))
.filter(lawsTag -> !lawsTag.getDbFieldName().equals(FieldCommon.REPLACED_BY_STANDARD))
.filter(lawsTag -> !lawsTag.getDbFieldName().equals(FieldCommon.REFERENCED_STANDARD))
.filter(lawsTag -> !lawsTag.getDbFieldName().equals(FieldCommon.STANDARD_NUMBER_TEMP))
.collect(Collectors.toList());
// 添加稽查内容字段
@@ -1,7 +1,6 @@
package com.jero.modules.laws.common.util;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.constant.enums.YesOrNoEnum;
@@ -17,7 +16,6 @@ import com.jero.modules.laws.standardization.service.ILawsStandardizationService
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.system.entity.SysDepart;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.service.ISysDepartService;
import com.jero.modules.system.service.ISysDictItemService;
@@ -305,7 +303,7 @@ public class ImportUtil {
// 转成字典值并存入
parameterMap.put(FieldCommon.ENTERPRISE_STANDARD_CODE, this.convertDictValue("enterprise_standard_code", enterpriseStandardCode));
parameterMap.put(FieldCommon.ENTERPRISE_NAME_CODE, this.convertDictValue("enterprise_name_code", enterpriseNameCode));
parameterMap.put(FieldCommon.STANDARD_CATEGORY_CODE, this.convertDictValue("standard_category_code", categoryCode));
parameterMap.put(FieldCommon.STANDARD_CATEGORY_CODE, this.convertStandardCategoryCode(categoryCode));
parameterMap.put(FieldCommon.YEAR_NUMBER, yearCode);
}
// 判断是否有重复数据
@@ -538,6 +536,19 @@ public class ImportUtil {
return errMsgList;
}
private Object convertStandardCategoryCode(String cellValue) {
String[] valueList = cellValue.split(",");
Map<String, DictModel> sexDictModelMap =
sysBaseAPI.getDictItems("standard_category_code").stream()
.collect(Collectors.toMap(e -> e.getText().split("")[0], d -> d));
StringBuilder result = new StringBuilder();
for (String value : valueList) {
result.append(sexDictModelMap.get(value).getValue()).append(",");
}
// 去除掉最后的逗号
return result.substring(0, result.length() - 1);
}
private String convertBiddingCommitteeValid(String cellValue) {
List<String> valueList = Arrays.asList(cellValue.split(","));
LambdaQueryWrapper<LawsStandardization> wrapper = new LambdaQueryWrapper<>();