|
@@ -0,0 +1,59 @@
|
|
|
+package com.szwl.handle.response;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.szwl.constant.OperationType;
|
|
|
+import com.szwl.model.entity.MessageLog;
|
|
|
+import com.szwl.model.entity.TAlarmRecord;
|
|
|
+import com.szwl.model.entity.TEquipment;
|
|
|
+import com.szwl.service.TAlarmRecordService;
|
|
|
+import com.szwl.service.TEquipmentService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class EliminateProcessor implements ResponseProcessor{
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TEquipmentService tEquipmentService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TAlarmRecordService tAlarmRecordService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void process(MessageLog messageLog) {
|
|
|
+ Integer statusCode = messageLog.getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ Integer direction = messageLog.getDirection();
|
|
|
+ String clientId = messageLog.getClientId();
|
|
|
+ String responseContent = messageLog.getResponseContent();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getClientId, clientId);
|
|
|
+ TEquipment equipment = tEquipmentService.getOne(query);
|
|
|
+ if (equipment != null) {
|
|
|
+ // 消除过往的报警
|
|
|
+ LambdaUpdateWrapper<TAlarmRecord> wrapper = Wrappers.lambdaUpdate();
|
|
|
+ wrapper.eq(TAlarmRecord::getClientId, clientId);
|
|
|
+ wrapper.eq(TAlarmRecord::getIsEliminate, 0);
|
|
|
+ wrapper.le(TAlarmRecord::getCreateDate, new Date());
|
|
|
+ wrapper.set(TAlarmRecord::getIsEliminate, 1);
|
|
|
+ tAlarmRecordService.update(wrapper);
|
|
|
+ // 更改机器状态
|
|
|
+ equipment.setIsAlarm(false);
|
|
|
+ tEquipmentService.updateById(equipment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getSupportedOperationType() {
|
|
|
+ return OperationType.ELIMINATE.getCode();
|
|
|
+ }
|
|
|
+}
|