|
@@ -1,11 +1,18 @@
|
|
|
package com.ozs.service.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.ozs.service.entity.BaseDeviceDynamicManagement;
|
|
|
import com.ozs.service.entity.MqLog;
|
|
|
+import com.ozs.service.mapper.BaseDeviceDynamicManagementMapper;
|
|
|
import com.ozs.service.mapper.MqLogMapper;
|
|
|
import com.ozs.service.service.MqLogService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -18,12 +25,22 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class MqLogServiceImpl extends ServiceImpl<MqLogMapper, MqLog> implements MqLogService {
|
|
|
@Autowired
|
|
|
- MqLogMapper mqLogMapper;
|
|
|
+ private MqLogMapper mqLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private BaseDeviceDynamicManagementMapper baseDeviceDynamicManagementMapper;
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void insetHeartLog(String cameraCode) {
|
|
|
MqLog mqLog = new MqLog();
|
|
|
mqLog.setCameraCode(cameraCode);
|
|
|
- mqLogMapper.insert(mqLog);
|
|
|
+ int insert = mqLogMapper.insert(mqLog);
|
|
|
+ if (insert > 0) {
|
|
|
+ // 使用 LambdaUpdateWrapper进行更新
|
|
|
+ LambdaUpdateWrapper<BaseDeviceDynamicManagement> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(BaseDeviceDynamicManagement::getCameraCode, cameraCode)
|
|
|
+ .set(BaseDeviceDynamicManagement::getHeartTime, new Date());
|
|
|
+ baseDeviceDynamicManagementMapper.update(null, updateWrapper);
|
|
|
+ }
|
|
|
}
|
|
|
}
|