|
|
@@ -97,12 +97,34 @@ public class MesDeviceAlarmService extends CrudService<MesDeviceAlarmDao, MesDev
|
|
|
query.setDeviceSn(deviceSn);
|
|
|
List<MesDeviceAlarm> list = super.findList(query);
|
|
|
for (MesDeviceAlarm alarm : list) {
|
|
|
- // 状态无变化时跳过,避免无意义的更新
|
|
|
if (state != null && state.equals(alarm.getState())) {
|
|
|
continue;
|
|
|
}
|
|
|
alarm.setState(state);
|
|
|
- // 注意:state 是业务状态字段,需用 update(updateStatus 改的是框架的 status 字段)
|
|
|
+ super.update(alarm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据设备编号 + 报警类型更新报警状态
|
|
|
+ * @param deviceSn 设备编号
|
|
|
+ * @param type 报警类型(与 mes_device_alarm.type 一致)
|
|
|
+ * @param state 状态:0=待处理,1=已处理
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public void updateStateByDeviceSnAndType(String deviceSn, String type, String state) {
|
|
|
+ if (deviceSn == null || deviceSn.isEmpty() || type == null || type.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ MesDeviceAlarm query = new MesDeviceAlarm();
|
|
|
+ query.setDeviceSn(deviceSn);
|
|
|
+ query.setType(type);
|
|
|
+ List<MesDeviceAlarm> list = super.findList(query);
|
|
|
+ for (MesDeviceAlarm alarm : list) {
|
|
|
+ if (state != null && state.equals(alarm.getState())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ alarm.setState(state);
|
|
|
super.update(alarm);
|
|
|
}
|
|
|
}
|