feat: 通用导入删除不必要代码

This commit is contained in:
2024-06-29 18:34:04 +08:00
parent e4aa0ecd07
commit 90ace05bba
3 changed files with 10 additions and 109 deletions
@@ -122,9 +122,6 @@ public class FieldCommon {
public static final String STANDARD_SYSTEM = "standard_system";
// 标准类别
public static final String STANDARD_CLASS = "standard_class";
// 分标委
public static final String BIDDING_COMMITTEE = "bidding_committee";
// 代替标准号
public static final String REPLACED_STANDARD = "substitute_standard_number";
// 被代替标准号
@@ -519,13 +519,6 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
resultMap.put(key + FieldCommon._DICT_TEXT, StringUtils.join(fileList.stream()
.map(OSSFile::getFileName).collect(Collectors.toList()), ","));
}
} else if (FieldCommon.BIDDING_COMMITTEE.equals(key) && StringUtils.isNotBlank(value)) {
// 如果是分标委
// LawsStandardization lawsStandardization = lawsStandardizationService.getById(value);
// resultMap.put(key, value);
// if (!Objects.isNull(lawsStandardization)) {
// resultMap.put(key + FieldCommon._DICT_TEXT, lawsStandardization.getName());
// }
} else if (FieldCommon.PART_NAME.equals(key) && StringUtils.isNotBlank(value)) {
// 如果是零部件
LambdaQueryWrapper<PartName> partNameLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -1774,15 +1767,15 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
}
}
// 如果是企标的话手动添加稽查内容字段
if (TableNameEnum.ENTERPRISE_STANDARDS.getTableName().equals(tableName)) {
LawsTag inspectContentTag = new LawsTag();
inspectContentTag.setDbFieldTxt("稽查内容");
inspectContentTag.setFieldShowType(FieldShowTypeEnum.INSPECT_CONTENT_FILE_UPLOAD.getValue());
inspectContentTag.setDbFieldName(FieldCommon.CHECK_LIST);
inspectContentTag.setFieldMustInput(YesOrNoEnum.NO.getValue());
headerList.remove(headerList.size() - 1);
headerList.add(inspectContentTag);
}
// if (TableNameEnum.ENTERPRISE_STANDARDS.getTableName().equals(tableName)) {
// LawsTag inspectContentTag = new LawsTag();
// inspectContentTag.setDbFieldTxt("稽查内容");
// inspectContentTag.setFieldShowType(FieldShowTypeEnum.INSPECT_CONTENT_FILE_UPLOAD.getValue());
// inspectContentTag.setDbFieldName(FieldCommon.CHECK_LIST);
// inspectContentTag.setFieldMustInput(YesOrNoEnum.NO.getValue());
// headerList.remove(headerList.size() - 1);
// headerList.add(inspectContentTag);
// }
// 获取错误信息
errMsgList = importUtil.validExcelData(sheet, headerList, fileMap, insertDataList);
}
@@ -2153,26 +2146,6 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
selectCondition.append(sql);
parameterMap.remove(FieldCommon.PART_NAME);
}
// 分标委
String biddingCommittee = (String) parameterMap.get(FieldCommon.BIDDING_COMMITTEE);
if (StrUtil.isNotBlank(biddingCommittee)) {
// LambdaQueryWrapper<LawsStandardization> standardizationWrapper = new LambdaQueryWrapper<>();
// standardizationWrapper.eq(LawsStandardization::getPid, "0");
// LawsStandardization rootNode = lawsStandardizationService.getOne(standardizationWrapper);
// standardizationWrapper.clear();
// standardizationWrapper.eq(LawsStandardization::getPid, rootNode.getId());
// List<LawsStandardization> nodeList = lawsStandardizationService.list(standardizationWrapper);
// String sql = nodeList.stream()
// .map(item -> "'" + item.getId() + "'")
// .collect(Collectors.joining(","));
// // 拼接SQL
// selectCondition.append(" AND bidding_committee IN (");
// if (StrUtil.isBlank(sql)) {
// sql = "''";
// }
// selectCondition.append(sql).append(")");
// parameterMap.remove(FieldCommon.BIDDING_COMMITTEE);
}
if (idSearch) {
String idSql = idSet.stream()
@@ -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;
@@ -15,10 +14,8 @@ import com.jero.modules.laws.standard.service.*;
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;
import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.tag.entity.LawsTag;
import com.jero.modules.tag.enums.FieldShowTypeEnum;
@@ -65,9 +62,6 @@ public class ImportUtil {
@Resource
private IOSSFileService ossFileService;
@Resource
private ISysDictItemService sysDictItemService;
@Resource
private ILawsEnterpriseStandardService lawsEnterpriseStandardService;
@@ -84,8 +78,6 @@ public class ImportUtil {
// 从数据行开始遍历
for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) {
int line = i + 1;
boolean needValidMustInput = true;
String standardProperty = "";
String standardNumber = "";
String standardClass = "";
String yearNumber = "";
@@ -94,8 +86,6 @@ public class ImportUtil {
Date implementationDate = null;
String implementationDateRow = "";
StringBuilder errMsg = new StringBuilder("" + line + "");
boolean isGbFbNeedValidDate = false;
List<String> doNotValidDateStandardStateList = Arrays.asList("起草", "征求意见", "报批");
Map<String, Object> parameterMap = new HashMap<>();
boolean standardValidFlag = false;
// 跳过空行
@@ -207,30 +197,6 @@ public class ImportUtil {
}
}
// 国内标准 标准性质为推荐性的时候 零部件名称 适用认证 适用车型 非必填
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) &&
standardProperty.equals("推荐性") && (
FieldCommon.PART_NAME.equals(tag.getDbFieldName()) ||
FieldCommon.APPLICABLE_CERTIFICATION.equals(tag.getDbFieldName()) ||
FieldCommon.APPLICABLE_VEHICLE.equals(tag.getDbFieldName())
)) {
needValidMustInput = false;
}
// 必填验证
if (YesOrNoEnum.YES.getValue().equals(tag.getFieldMustInput()) && needValidMustInput) {
// 国内标准 标准状态为起草 征求意见 报批 状态的发布日期实施日期不是必填项
if (!((TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel())) &&
!isGbFbNeedValidDate &&
(FieldCommon.RELEASE_DATE.equals(tag.getDbFieldName()) ||
FieldCommon.IMPLEMENTATION_DATE.equals(tag.getDbFieldName())))) {
if (!this.mustInputValid(cell)) {
log.error("" + row + "" + tag.getDbFieldTxt() + "为必填 ");
errMsg.append("").append(row).append("").append(tag.getDbFieldTxt()).append("为必填 ");
continue;
}
}
}
// 获取当前单元格内容
if (cell == null) {
continue;
@@ -306,37 +272,12 @@ public class ImportUtil {
}
}
// 分标委
if (FieldCommon.BIDDING_COMMITTEE.equals(tag.getDbFieldName())) {
if (!this.biddingCommitteeValid(cellValue)) {
log.error("" + row + "" + tag.getDbFieldTxt() + "填写错误 ");
errMsg.append("").append(row).append("").append(tag.getDbFieldTxt()).append("填写错误 ");
} else {
// 转为id
cellValue = this.convertBiddingCommitteeValid(cellValue);
}
}
// 下拉单选
if (FieldShowTypeEnum.DROPDOWN_SINGLE_SELECT.getValue().equals(tag.getFieldShowType()) &&
!FieldCommon.BIDDING_COMMITTEE.equals(tag.getDbFieldName())) {
if (FieldShowTypeEnum.DROPDOWN_SINGLE_SELECT.getValue().equals(tag.getFieldShowType())) {
if (!this.singleDictValid(tag.getDictField(), cellValue)) {
log.error("" + row + "" + tag.getDbFieldTxt() + "填写错误 ");
errMsg.append("").append(row).append("").append(tag.getDbFieldTxt()).append("填写错误 ");
} else {
// 如果是国标
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel())) {
// 标准状态
if (FieldCommon.STANDARD_STATE.equals(tag.getDbFieldName())) {
// 设置是否需要校验发布日期 实施日期
isGbFbNeedValidDate = !doNotValidDateStandardStateList.contains(cellValue);
}
// 标准性质
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) &&
FieldCommon.STANDARD_PROPERTY.equals(tag.getDbFieldName())) {
standardProperty = cellValue;
}
}
// 转为value
cellValue = this.convertDictValue(tag.getDictField(), cellValue);
}
@@ -482,16 +423,6 @@ public class ImportUtil {
}
}
}
// 判断实施日期是否大于发布日期15天
if (releaseDate != null && implementationDate != null) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(implementationDate);
calendar.add(Calendar.DAY_OF_MONTH, -15);
if (!releaseDate.before(calendar.getTime())) {
log.error("" + implementationDateRow + "列的实施日期必须大于第" + releaseDateRow + "列的发布日期15天 ");
errMsg.append("").append(implementationDateRow).append("列的实施日期必须大于第").append(releaseDateRow).append("列的发布日期15天 ");
}
}
if (errMsg.toString().contains("") || errMsg.toString().contains("重复") || errMsg.toString().contains("已存在")) {
errMsgList.add(errMsg.toString());
} else {