feat(excel): 添加Excel导入别名支持和改进导入功能

- 在Excel注解中新增aliasNames属性,支持多语言列名匹配
- 实现importExcelCopy方法,提供增强的Excel导入功能
- 添加对物模型实体的别名配置,支持Description、Name等多种列名
- 实现基于别名的字段映射匹配逻辑
- 修复标识符重复校验逻辑,确保数据完整性
- 优化Excel导入过程中的数据类型转换处理

Signed-off-by: Gjm <你的邮箱>
This commit is contained in:
Gjm
2026-04-10 16:12:45 +08:00
parent a65b23cdad
commit bd3328f332
5 changed files with 238 additions and 11 deletions

View File

@@ -30,8 +30,7 @@ public class ThingsModel extends BaseEntity
/** 物模型名称 */
@ApiModelProperty("物模型名称")
@Excel(name = "Description" ,prompt = "必填")
private String modelName;
@Excel(name = "物模型名称", aliasNames = {"Description", "Name"}, prompt = "必填") private String modelName;
/** 物模型名称 */
@@ -60,7 +59,7 @@ public class ThingsModel extends BaseEntity
/** 标识符,产品下唯一 */
@ApiModelProperty("标识符,产品下唯一")
@Excel(name = "MeasuringPointName",prompt = "modbus不填默认为寄存器地址")
@Excel(name = "标识符", aliasNames = {"MeasuringPointName", "Identifier"}, prompt = "modbus不填默认为寄存器地址")
private String identifier;
/** 模型类别1-属性2-功能3-事件) */
@@ -111,7 +110,7 @@ public class ThingsModel extends BaseEntity
/** 数据类型integer、decimal、string、bool、array、enum */
@ApiModelProperty(value = "数据类型", notes = "integer、decimal、string、bool、array、enum")
@Excel(name = "DataType", prompt = "integer、decimal、string、bool、array、enum")
@Excel(name = "数据类型", aliasNames = {"DataType"}, prompt = "integer、decimal、string、bool、array、enum")
private String datatype;
@Excel(name = "有效值范围")

View File

@@ -410,12 +410,12 @@ public class ThingsModelServiceImpl implements IThingsModelService {
failSb.append("<br/>").append(failure).append(",采集点: ").append(model.getModelName()).append("导入失败");
}
}
// if (result) {
// log.error("标识符不能重复");
// failure++;
// failSb.append("<br/>").append(failure).append(",采集点: ").append("标识符不能重复");
// throw new ServiceException(failSb.toString());
// }
if (result) {
log.error("标识符不能重复");
failure++;
failSb.append("<br/>").append(failure).append(",采集点: ").append("标识符不能重复");
throw new ServiceException(failSb.toString());
}
if (failure > 0) {
throw new ServiceException(failSb.toString());
}