fix:修复已知bug

liutao_branch
HuangHuiKang 2 weeks ago
parent f1dd991cde
commit 827dd9a071

@ -41,7 +41,7 @@ public class DeviceRespVO {
private String deviceType; private String deviceType;
@Schema(description = "状态", example = "1") @Schema(description = "状态", example = "1")
@ExcelProperty(value = "连接状态", converter = DictConvert.class) // @ExcelProperty(value = "连接状态", converter = DictConvert.class)
@DictFormat("iot_gateway_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 @DictFormat("iot_gateway_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String status; private String status;
@ -66,7 +66,7 @@ public class DeviceRespVO {
private Long offLineDuration; private Long offLineDuration;
@Schema(description = "最后上线时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "最后上线时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("最后上线时间") // @ExcelProperty("最后上线时间")
private LocalDateTime lastOnlineTime; private LocalDateTime lastOnlineTime;
@Schema(description = "备注", example = "你说的对") @Schema(description = "备注", example = "你说的对")
@ -92,19 +92,19 @@ public class DeviceRespVO {
private String protocol; private String protocol;
@Schema(description = "采集周期", example = "30") @Schema(description = "采集周期", example = "30")
@ExcelProperty("采集周期") // @ExcelProperty("采集周期")
private Double sampleCycle; private Double sampleCycle;
@Schema(description = "端点url", example = "opc.tcp://127.0.0.1:48401") @Schema(description = "端点url", example = "opc.tcp://127.0.0.1:48401")
@ExcelProperty("端点url") // @ExcelProperty("端点url")
private String url; private String url;
@Schema(description = "用户名", example = "admin") @Schema(description = "用户名", example = "admin")
@ExcelProperty("用户名") // @ExcelProperty("用户名")
private String username; private String username;
@Schema(description = "密码", example = "1234") @Schema(description = "密码", example = "1234")
@ExcelProperty("密码") // @ExcelProperty("密码")
private String password; private String password;
@Schema(description = "运行状态") @Schema(description = "运行状态")
@ -124,5 +124,6 @@ public class DeviceRespVO {
private Long org; private Long org;
@Schema(description = "mqtt订阅主题") @Schema(description = "mqtt订阅主题")
@ExcelProperty("mqtt订阅主题")
private String topic; private String topic;
} }

@ -24,7 +24,6 @@ public class DeviceContactModelRespVO {
private String attributeName; private String attributeName;
@Schema(description = "点位类型", example = "1") @Schema(description = "点位类型", example = "1")
@ExcelProperty("点位类型")
private String attributeType; private String attributeType;
@Schema(description = "数据类型", example = "1") @Schema(description = "数据类型", example = "1")
@ -48,7 +47,7 @@ public class DeviceContactModelRespVO {
private String remark; private String remark;
@Schema(description = "采集设备模型id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13862") @Schema(description = "采集设备模型id", requiredMode = Schema.RequiredMode.REQUIRED, example = "13862")
@ExcelProperty("采集设备模型id") // @ExcelProperty("采集设备模型id")
private Long deviceModelId; private Long deviceModelId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ -60,6 +59,7 @@ public class DeviceContactModelRespVO {
private int sort; private int sort;
@Schema(description = "采集点类型名称", example = "1") @Schema(description = "采集点类型名称", example = "1")
@ExcelProperty("点位类型")
private String typeName; private String typeName;

@ -138,7 +138,7 @@ public class DeviceModelAttributeController {
.attributeCode("temperature_001") .attributeCode("temperature_001")
.attributeName("温度") .attributeName("温度")
// .attributeType("1") // .attributeType("1")
.typeName("报警信息") .typeCode("SBCS")
.dataType("float") .dataType("float")
.address("AI0") .address("AI0")
.dataUnit("s") .dataUnit("s")
@ -149,7 +149,7 @@ public class DeviceModelAttributeController {
.attributeCode("humidity_001") .attributeCode("humidity_001")
.attributeName("湿度") .attributeName("湿度")
// .attributeType("2") // .attributeType("2")
.typeName("能源参数") .typeCode("PROC")
.dataType("double") .dataType("double")
.address("AI1") .address("AI1")
.dataUnit("s") .dataUnit("s")

@ -33,8 +33,8 @@ public class DeviceModelAttributeImportExcelVO {
@ExcelIgnore @ExcelIgnore
private String attributeType; private String attributeType;
@ExcelProperty("点位类型名称") @ExcelProperty("点位类型编码")
private String typeName; private String typeCode;
@ExcelProperty(value = "数据类型") // 对应 User 的 "用户性别" @ExcelProperty(value = "数据类型") // 对应 User 的 "用户性别"
// , converter = DictConvert.class // , converter = DictConvert.class

@ -25,6 +25,10 @@ public class DeviceModelAttributeRespVO {
@ExcelProperty("点位名称") @ExcelProperty("点位名称")
private String attributeName; private String attributeName;
@Schema(description = "采集点位类型编码", example = "1")
@ExcelProperty("采集点位类型编码")
private String attributeTypeCode;
@Schema(description = "点位类型", example = "1") @Schema(description = "点位类型", example = "1")
@ExcelProperty("点位类型") @ExcelProperty("点位类型")
private String attributeType; private String attributeType;
@ -66,5 +70,4 @@ public class DeviceModelAttributeRespVO {
private LocalDateTime createTime; private LocalDateTime createTime;
} }

@ -58,6 +58,6 @@ public class TimeConverterUtil {
* *
*/ */
public static String getPercentString(double value) { public static String getPercentString(double value) {
return formatDouble(value, 2) + "%"; return formatDouble(value * 100, 2) + "%";
} }
} }

@ -32,7 +32,7 @@ public interface DeviceModelAttributeService {
/** /**
* - * -
* *
* @param id * @param idList
*/ */
void deleteDeviceModelAttribute(List<Long> idList ); void deleteDeviceModelAttribute(List<Long> idList );

@ -126,6 +126,7 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
// 获取设备模型属性分页数据 // 获取设备模型属性分页数据
PageResult<DeviceModelAttributeDO> pageResult = deviceModelAttributeMapper.selectPage(pageReqVO); PageResult<DeviceModelAttributeDO> pageResult = deviceModelAttributeMapper.selectPage(pageReqVO);
// // 获取所有属性类型并构建映射 // // 获取所有属性类型并构建映射
// List<DeviceAttributeTypeDO> attributeTypes = deviceAttributeTypeMapper.selectList(); // List<DeviceAttributeTypeDO> attributeTypes = deviceAttributeTypeMapper.selectList();
// Map<Long, String> typeNameMap = attributeTypes.stream() // Map<Long, String> typeNameMap = attributeTypes.stream()
@ -158,6 +159,30 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
} }
}); });
List<DeviceModelAttributeRespVO> list = respPageResult.getList();
if (CollUtil.isEmpty(list)) {
return respPageResult;
}
// 收集 attributeType
Set<String> typeIds = list.stream()
.map(DeviceModelAttributeRespVO::getAttributeType)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if (CollUtil.isEmpty(typeIds)) {
return respPageResult;
}
// 查询并转成 id -> code
Map<Long, String> typeCodeMap = deviceAttributeTypeMapper.selectBatchIds(typeIds)
.stream()
.collect(Collectors.toMap(DeviceAttributeTypeDO::getId, DeviceAttributeTypeDO::getCode));
// 赋值
list.forEach(item ->
item.setAttributeTypeCode(typeCodeMap.get(Long.valueOf(item.getAttributeType())))
);
// respPageResult.getList().forEach(item -> { // respPageResult.getList().forEach(item -> {
// String typeName = typeNameMap.get(item.getAttributeType()); // String typeName = typeNameMap.get(item.getAttributeType());
// if (typeName != null) { // if (typeName != null) {
@ -245,8 +270,12 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
// 2. 构建点位类型名称到ID的映射 // 2. 构建点位类型名称到ID的映射
List<DeviceAttributeTypeDO> attributeTypes = deviceAttributeTypeMapper.selectList(); List<DeviceAttributeTypeDO> attributeTypes = deviceAttributeTypeMapper.selectList();
Map<String, String> typeNameToIdMap = attributeTypes.stream() Map<String, String> typeCodeToIdMap = attributeTypes.stream()
.collect(Collectors.toMap(DeviceAttributeTypeDO::getName, type -> String.valueOf(type.getId()))); .collect(Collectors.toMap(DeviceAttributeTypeDO::getCode, type -> String.valueOf(type.getId())));
Map<String, String> typeCodeToNameMap = attributeTypes.stream()
.collect(Collectors.toMap(DeviceAttributeTypeDO::getCode, DeviceAttributeTypeDO::getName));
// 3. 初始化返回 VO - 完全复刻 User 的 builder 方式,使用 LinkedHashMap 保持顺序 // 3. 初始化返回 VO - 完全复刻 User 的 builder 方式,使用 LinkedHashMap 保持顺序
@ -262,20 +291,20 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
importAttribute.setDeviceModelId(deviceModelId); importAttribute.setDeviceModelId(deviceModelId);
// 4.2 处理点位类型转换 // 4.2 处理点位类型转换
String typeName = importAttribute.getTypeName(); String code = importAttribute.getTypeCode();
// 不能为空 // 不能为空
if (StringUtils.isBlank(typeName)) { if (StringUtils.isBlank(code)) {
respVO.getFailureCodes().put(importAttribute.getAttributeCode(), "点位类型名称不能为空"); respVO.getFailureCodes().put(importAttribute.getAttributeCode(), "点位类型名称不能为空");
return; return;
} }
// 必须存在于数据库类型列表中(防止乱填) // 必须存在于数据库类型列表中(防止乱填)
if (!typeNameToIdMap.containsKey(typeName)) { if (!typeCodeToIdMap.containsKey(code)) {
respVO.getFailureCodes().put(importAttribute.getAttributeCode(), respVO.getFailureCodes().put(importAttribute.getAttributeCode(),
"点位类型名称不存在: " + typeName); "点位类型名称不存在: " + code);
return; return;
} }
String attributeTypeId = typeNameToIdMap.get(typeName); String attributeTypeId = typeCodeToIdMap.get(code);
// 设置点位类型ID // 设置点位类型ID
importAttribute.setAttributeType(attributeTypeId); importAttribute.setAttributeType(attributeTypeId);
@ -335,7 +364,7 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
// 不存在 → 新增 // 不存在 → 新增
DeviceModelAttributeDO deviceModelAttribute = DeviceModelAttributeDO deviceModelAttribute =
BeanUtils.toBean(importAttribute, DeviceModelAttributeDO.class); BeanUtils.toBean(importAttribute, DeviceModelAttributeDO.class);
deviceModelAttribute.setTypeName(typeName); deviceModelAttribute.setTypeName(typeCodeToNameMap.get(code));
deviceModelAttributeMapper.insert(deviceModelAttribute); deviceModelAttributeMapper.insert(deviceModelAttribute);
respVO.getCreateCodes().add(importAttribute.getAttributeCode()); respVO.getCreateCodes().add(importAttribute.getAttributeCode());
@ -348,7 +377,7 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
if (existAttribute == null) { if (existAttribute == null) {
DeviceModelAttributeDO deviceModelAttribute = DeviceModelAttributeDO deviceModelAttribute =
BeanUtils.toBean(importAttribute, DeviceModelAttributeDO.class); BeanUtils.toBean(importAttribute, DeviceModelAttributeDO.class);
deviceModelAttribute.setTypeName(typeName); deviceModelAttribute.setTypeName(typeCodeToNameMap.get(code));
deviceModelAttributeMapper.insert(deviceModelAttribute); deviceModelAttributeMapper.insert(deviceModelAttribute);
respVO.getCreateCodes().add(importAttribute.getAttributeCode()); respVO.getCreateCodes().add(importAttribute.getAttributeCode());
@ -359,7 +388,7 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
DeviceModelAttributeDO updateAttribute = DeviceModelAttributeDO updateAttribute =
BeanUtils.toBean(importAttribute, DeviceModelAttributeDO.class); BeanUtils.toBean(importAttribute, DeviceModelAttributeDO.class);
updateAttribute.setId(existAttribute.getId()); updateAttribute.setId(existAttribute.getId());
updateAttribute.setTypeName(typeName); updateAttribute.setTypeName(typeCodeToNameMap.get(code));
deviceModelAttributeMapper.updateById(updateAttribute); deviceModelAttributeMapper.updateById(updateAttribute);
respVO.getUpdateCodes().add(importAttribute.getAttributeCode()); respVO.getUpdateCodes().add(importAttribute.getAttributeCode());

@ -32,6 +32,10 @@ public class CriticalComponentExcelVO {
@ExcelProperty("描述") @ExcelProperty("描述")
private String description; private String description;
@Schema(description = "数量", example = "2")
@ExcelProperty("数量")
private Integer count;
@Schema(description = "备注") @Schema(description = "备注")
@ExcelProperty("备注") @ExcelProperty("备注")
private String remark; private String remark;
@ -41,4 +45,6 @@ public class CriticalComponentExcelVO {
@ColumnWidth(20) @ColumnWidth(20)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

@ -34,5 +34,7 @@ public class CriticalComponentPageReqVO extends PageParam {
@Schema(description = "id集合导出用") @Schema(description = "id集合导出用")
private String ids; private String ids;
@Schema(description = "数量", example = "2")
private Integer count;
} }

@ -38,4 +38,7 @@ public class CriticalComponentRespVO {
@ColumnWidth(20) @ColumnWidth(20)
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "数量", example = "2")
private Integer count;
} }

@ -26,4 +26,8 @@ public class CriticalComponentSaveReqVO {
@Schema(description = "备注", example = "你说的对") @Schema(description = "备注", example = "你说的对")
private String remark; private String remark;
@Schema(description = "数量", example = "2")
private Integer count;
} }

@ -43,5 +43,9 @@ public class CriticalComponentDO extends BaseDO {
* *
*/ */
private String remark; private String remark;
/**
*
*/
private Integer count;
} }
Loading…
Cancel
Save