|
@@ -0,0 +1,50 @@
|
|
|
|
|
+package com.usky.eg.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.usky.common.core.exception.BusinessException;
|
|
|
|
|
+import com.usky.eg.domain.EgDeviceHeartbeat;
|
|
|
|
|
+import com.usky.eg.mapper.EgDeviceHeartbeatMapper;
|
|
|
|
|
+import com.usky.eg.service.EgDeviceHeartbeatService;
|
|
|
|
|
+import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 门禁设备心跳表 服务实现类
|
|
|
|
|
+ * </p>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author fhs
|
|
|
|
|
+ * @since 2026-02-03
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class EgDeviceHeartbeatServiceImpl extends AbstractCrudService<EgDeviceHeartbeatMapper, EgDeviceHeartbeat> implements EgDeviceHeartbeatService {
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void heartbeatEscalation(EgDeviceHeartbeat heartbeat) {
|
|
|
|
|
+ if (StringUtils.isBlank(heartbeat.getDeviceCode())) {
|
|
|
|
|
+ throw new BusinessException("设备编码不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(heartbeat.getIpAddr())) {
|
|
|
|
|
+ throw new BusinessException("设备IP不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (heartbeat.getCreateTime() == null) {
|
|
|
|
|
+ heartbeat.setCreateTime(LocalDateTime.now());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (heartbeat.getDeviceType() == null) {
|
|
|
|
|
+ throw new BusinessException("设备类型不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 删除旧数据
|
|
|
|
|
+ LambdaQueryWrapper<EgDeviceHeartbeat> deleteWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ deleteWrapper.eq(EgDeviceHeartbeat::getDeviceCode, heartbeat.getDeviceCode());
|
|
|
|
|
+ baseMapper.delete(deleteWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ baseMapper.insert(heartbeat);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|