feat: 导入支持多个时间
This commit is contained in:
@@ -74,7 +74,6 @@ public class ImportUtil {
|
||||
if (cell == null) {
|
||||
return errMsgList;
|
||||
}
|
||||
// 单选时间
|
||||
String cellValue = cell.toString();
|
||||
|
||||
// 企标编号校验
|
||||
@@ -111,6 +110,7 @@ public class ImportUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 单选时间
|
||||
if (FieldShowTypeEnum.SINGLE_DATE_PICKER.getValue().equals(tag.getFieldShowType())) {
|
||||
Date date = cell.getDateCellValue();
|
||||
// 创建一个SimpleDateFormat对象,并指定所需的格式
|
||||
@@ -183,16 +183,6 @@ public class ImportUtil {
|
||||
cellValue = this.convertPartId(cellValue);
|
||||
}
|
||||
}
|
||||
// 多选组织机构
|
||||
if (FieldShowTypeEnum.MULTI_ORGANIZATION_DIALOG.getValue().equals(tag.getFieldShowType())) {
|
||||
if (!this.multiOrgValid(cellValue)) {
|
||||
log.error("第" + (i + 1) + "行第" + (j + 1) + "列选项" + tag.getDbFieldTxt() + "填写错误");
|
||||
errMsgList.add("第" + (i + 1) + "行第" + (j + 1) + "列选项" + tag.getDbFieldTxt() + "填写错误");
|
||||
} else {
|
||||
// 转为id
|
||||
cellValue = this.convertMultiOrgId(cellValue);
|
||||
}
|
||||
}
|
||||
// 体系
|
||||
if (FieldCommon.STANDARD_SYSTEM.equals(tag.getDbFieldName())) {
|
||||
if (!this.standardSystemValid(cellValue)) {
|
||||
@@ -213,12 +203,49 @@ public class ImportUtil {
|
||||
cellValue = this.convertFileIds(cellValue, fileMap);
|
||||
}
|
||||
}
|
||||
// TODO 多选时间
|
||||
// 多选时间
|
||||
if (FieldShowTypeEnum.MULTI_DATE_PICKER.getValue().equals(tag.getFieldShowType())) {
|
||||
if (!this.multiDateValid(cellValue)) {
|
||||
log.error("第" + (i + 1) + "行第" + (j + 1) + "列选项" + tag.getDbFieldTxt() + "填写错误");
|
||||
errMsgList.add("第" + (i + 1) + "行第" + (j + 1) + "列选项" + tag.getDbFieldTxt() + "填写错误");
|
||||
} else {
|
||||
// 转为id
|
||||
cellValue = this.multiDateConvert(cellValue);
|
||||
}
|
||||
}
|
||||
|
||||
// 将转好的值加入Map
|
||||
parameterMap.put(tag.getDbFieldName(), cellValue);
|
||||
return errMsgList;
|
||||
}
|
||||
|
||||
private String multiDateConvert(String cellValue) {
|
||||
String[] dates = cellValue.split(",");
|
||||
// 用英文逗号拼接
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
StringBuilder dateBuilder = new StringBuilder();
|
||||
for (String date : dates) {
|
||||
dateBuilder.append(sdf.format(date)).append(",");
|
||||
}
|
||||
return dateBuilder.toString();
|
||||
}
|
||||
|
||||
private boolean multiDateValid(String cellValue) {
|
||||
String[] dates = cellValue.split(",");
|
||||
// 创建一个SimpleDateFormat对象,并指定所需的格式
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 使用SimpleDateFormat对象的format方法将Date对象转换为字符串
|
||||
try {
|
||||
for (String date : dates) {
|
||||
sdf.format(date);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("日期转换错误:{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String convertFileIds(String cellValue, Map<String, File> fileMap) {
|
||||
String[] pathList = cellValue.split(",");
|
||||
StringBuilder fileIds = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user