10.27增加设备楼层信息

dev
xiaohuo 8 months ago
parent 73c643ab5b
commit 7f516a6e9b
  1. 3
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java
  2. 3
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java
  3. 74
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java
  4. 7
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml

@ -56,7 +56,8 @@ public class EquBase
@Excel(name = "设备类型 id")
private String equTypeId;
@Excel(name = "楼层位置")
private String floor;
public EquType getEquTypeVO() {
return equTypeVO;

@ -99,6 +99,9 @@ public class queryEquBaseVO {
@Excel(name = "设备编号")
private String equNumber;
@Excel(name = "楼层位置")
private String floor;
public void setId(String id)

@ -360,22 +360,70 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService {
executor.shutdown();
// ✅ 完整性校验:找出所有子表为空的设备
List<String> invalidDevices = successList.stream()
.filter(g -> g.getSubEntities() == null
|| g.getSubEntities().isEmpty()
|| g.getSubEntities().values().stream().anyMatch(list -> list == null || list.isEmpty()))
.map(g -> g.getEquGather().getEquId())
.collect(Collectors.toList());
// // ✅ 完整性校验:找出所有子表为空的设备
// List<String> invalidDevices = successList.stream()
// .filter(g -> g.getSubEntities() == null
// || g.getSubEntities().isEmpty()
// || g.getSubEntities().values().stream().anyMatch(list -> list == null || list.isEmpty()))
// .map(g -> g.getEquGather().getEquId())
// .collect(Collectors.toList());
//
// // 如果全部失败或者发现不完整设备,抛异常
// if (successList.isEmpty() || !invalidDevices.isEmpty()) {
// String msg = "本次采集失败,保持旧数据完好。失败设备:" +
// String.join(", ", failed) +
// (invalidDevices.isEmpty() ? "" : ",采集数据不完整设备:" + String.join(", ", invalidDevices));
// log.error(msg);
// throw new RuntimeException(msg); // 异常抛出去,外层可捕获发送邮件
// }
// ✅ 完整性校验:找出所有子表为空的设备及对应子表
Map<String, List<String>> invalidDeviceMap = successList.stream()
.map(g -> {
String equId = g.getEquGather().getEquId();
// 找出这个设备下不完整的子表
List<String> emptyTables = new ArrayList<>();
// subEntities 为空或没有数据
if (g.getSubEntities() == null || g.getSubEntities().isEmpty()) {
emptyTables.add("所有子表为空");
} else {
// 检查每个子表的值
g.getSubEntities().forEach((tableName, list) -> {
if (list == null || list.isEmpty()) {
emptyTables.add(tableName);
}
});
}
// 如果全部失败或者发现不完整设备,抛异常
// 如果有任何空子表,返回 (设备ID, 空表列表)
return emptyTables.isEmpty() ? null : Map.entry(equId, emptyTables);
})
.filter(Objects::nonNull)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
// ✅ 提取不完整设备ID列表
List<String> invalidDevices = new ArrayList<>(invalidDeviceMap.keySet());
// ✅ 如果全部失败或有不完整设备,抛异常
if (successList.isEmpty() || !invalidDevices.isEmpty()) {
String msg = "本次采集失败,保持旧数据完好。失败设备:" +
String.join(", ", failed) +
(invalidDevices.isEmpty() ? "" : ",采集数据不完整设备:" + String.join(", ", invalidDevices));
log.error(msg);
throw new RuntimeException(msg); // 异常抛出去,外层可捕获发送邮件
StringBuilder msg = new StringBuilder("本次采集失败,保持旧数据完好。");
if (!failed.isEmpty()) {
msg.append("失败设备:").append(String.join(", ", failed));
}
if (!invalidDeviceMap.isEmpty()) {
msg.append(";采集数据不完整设备如下:");
invalidDeviceMap.forEach((equId, tables) ->
msg.append("\n设备[").append(equId).append("] 缺少表:")
.append(String.join(", ", tables)));
}
log.error(msg.toString());
throw new RuntimeException(msg.toString());
}
// 事务内:删除旧表 + 插入成功设备数据
deleteAllEquipmentData(); // 删除依附表,不含 equ_gather
int inserted = persistAndUpdate(successList); // 插入成功设备数据

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="gatherFrequency" column="gather_frequency" />
<result property="equImage" column="equ_image" />
<result property="equNumber" column="equ_number" />
<result property="floor" column="floor" />
<association property="manufactureVO" columnPrefix="equ_manu_" autoMapping="true" />
<association property="equTypeVO" columnPrefix="equ_type_" autoMapping="true" />
@ -159,7 +160,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.status AS status,
b.device_level AS deviceLevel,
g.health AS health,
b.equ_image AS equImage
b.equ_image AS equImage,
b.floor AS floor
</sql>
<select id="selectEquBaseList" parameterType="equBaseQueryDto" resultType="com.alops.system.domain.vo.queryEquBaseVO">
@ -434,6 +436,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">create_by,</if>
<if test="createDate != null">create_date,</if>
<if test="equNumber != null">equ_number,</if>
<if test="floor != null">floor,</if>
status,
<if test="equImage != null">equ_image,</if>
@ -457,6 +460,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="equNumber != null">#{equNumber},</if>
<if test="floor != null">#{floor},</if>
COALESCE(#{status,jdbcType=INTEGER}, 0),
<if test="equImage != null">#{equImage},</if>
COALESCE(#{failureFrequency,jdbcType=BIGINT}, 0),
@ -485,6 +489,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierId != null">supplier_id = #{supplierId},</if>
<if test="equImage != null">equ_image = #{equImage},</if>
<if test="equNumber != null">equ_number = #{equNumber},</if>
<if test="floor != null">floor = #{floor},</if>
</trim>
where id = #{id}
</update>

Loading…
Cancel
Save