68 lines
1.6 KiB
Java
68 lines
1.6 KiB
Java
package com.common.service;
|
|
|
|
import com.common.entity.DeviceInterlockingLog;
|
|
import com.common.mapper.DeviceInterlockingLogMapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
|
|
@Service
|
|
public class DeviceInterlockingLogService {
|
|
|
|
@Autowired
|
|
private DeviceInterlockingLogMapper logMapper;
|
|
|
|
/**
|
|
* 根据ID查询
|
|
*/
|
|
public DeviceInterlockingLog selectById(Long id) {
|
|
return logMapper.selectById(id);
|
|
}
|
|
|
|
/**
|
|
* 根据指令ID查询
|
|
*/
|
|
public List<DeviceInterlockingLog> selectByCmdId(Long cmdId) {
|
|
return logMapper.selectByCmdId(cmdId);
|
|
}
|
|
|
|
/**
|
|
* 插入记录
|
|
*/
|
|
public int insert(DeviceInterlockingLog log) {
|
|
if (log.getBanTime() == null) {
|
|
log.setBanTime(LocalDateTime.now());
|
|
}
|
|
return logMapper.insert(log);
|
|
}
|
|
|
|
/**
|
|
* 批量插入记录
|
|
*/
|
|
public int batchInsert(List<DeviceInterlockingLog> logs) {
|
|
if (logs != null && !logs.isEmpty()) {
|
|
for (DeviceInterlockingLog log : logs) {
|
|
if (log.getBanTime() == null) {
|
|
log.setBanTime(LocalDateTime.now());
|
|
}
|
|
}
|
|
}
|
|
return logMapper.batchInsert(logs);
|
|
}
|
|
|
|
/**
|
|
* 查询所有记录
|
|
*/
|
|
public List<DeviceInterlockingLog> selectAll() {
|
|
return logMapper.selectAll();
|
|
}
|
|
|
|
/**
|
|
* 统计某指令的成功/失败数量
|
|
*/
|
|
public List<java.util.Map<String, Object>> countByCmdId(Long cmdId) {
|
|
return logMapper.countByCmdId(cmdId);
|
|
}
|
|
}
|