| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.DeviceOperationLog; |
| | | import com.sandu.ximon.dao.mapper.DeviceOperationLogMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author LHN |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class DeviceOperationLogService extends BaseServiceImpl<DeviceOperationLogMapper, DeviceOperationLog> { |
| | | |
| | | private final DeviceOperationLogMapper deviceOperationLogMapper; |
| | | |
| | | /** |
| | | * 获取操作日志列表 |
| | | * |
| | | * @param baseConditionVO |
| | | * @param poleCode |
| | | * @param operation |
| | | * @return |
| | | */ |
| | | public List<DeviceOperationLog> getLogList(BaseConditionVO baseConditionVO, String poleCode, String operation) { |
| | | |
| | | LambdaQueryWrapper<DeviceOperationLog> lambdaQueryWrapper = Wrappers.lambdaQuery(DeviceOperationLog.class); |
| | | if (poleCode != null && poleCode.trim().length() != 0) { |
| | | lambdaQueryWrapper.like(DeviceOperationLog::getPoleCode, poleCode); |
| | | } |
| | | if (operation != null && operation.trim().length() != 0) { |
| | | lambdaQueryWrapper.like(DeviceOperationLog::getOperation, operation); |
| | | } |
| | | lambdaQueryWrapper.orderByDesc(DeviceOperationLog::getId); |
| | | |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | } |
| | | List<DeviceOperationLog> list = list(lambdaQueryWrapper); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 保存设备操作日志 |
| | |
| | | * @param poleCode |
| | | */ |
| | | public void saveDeviceOperationLog(String deviceCode, String deviceName, String operation, String content, String poleCode) { |
| | | DeviceOperationLog deviceOperationLog = new DeviceOperationLog(); |
| | | deviceOperationLog.setUserId(SecurityUtils.getUserId()); |
| | | deviceOperationLog.setUserName(SecurityUtils.getUsername()); |
| | | if (deviceCode != null && !"[]".equals(deviceCode)) { |
| | | deviceOperationLog.setDeviceCode(deviceCode); |
| | | try { |
| | | DeviceOperationLog deviceOperationLog = new DeviceOperationLog(); |
| | | deviceOperationLog.setUserId(SecurityUtils.getUserId()); |
| | | deviceOperationLog.setUserName(SecurityUtils.getUsername()); |
| | | if (deviceCode != null && !"[]".equals(deviceCode)) { |
| | | deviceOperationLog.setDeviceCode(deviceCode); |
| | | } |
| | | if (deviceName != null) { |
| | | deviceOperationLog.setDeviceName(deviceName); |
| | | } |
| | | deviceOperationLog.setOperation(operation); |
| | | deviceOperationLog.setContent(content); |
| | | if (poleCode != null && !"[]".equals(poleCode)) { |
| | | deviceOperationLog.setPoleCode(poleCode); |
| | | } |
| | | this.save(deviceOperationLog); |
| | | } catch (Exception e) { |
| | | System.out.println("存储操作帧失败,数据异常"); |
| | | } |
| | | if (deviceName != null) { |
| | | deviceOperationLog.setDeviceName(deviceName); |
| | | } |
| | | deviceOperationLog.setOperation(operation); |
| | | deviceOperationLog.setContent(content); |
| | | if (poleCode != null && !"[]".equals(poleCode)) { |
| | | deviceOperationLog.setPoleCode(poleCode); |
| | | } |
| | | this.save(deviceOperationLog); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param content |
| | | */ |
| | | public void storeOperationLoginData(Long userId, String UserName, String operation, String content) { |
| | | DeviceOperationLog deviceOperationLog = new DeviceOperationLog(); |
| | | deviceOperationLog.setUserId(userId); |
| | | deviceOperationLog.setUserName(UserName); |
| | | deviceOperationLog.setOperation(operation); |
| | | deviceOperationLog.setContent(content); |
| | | this.save(deviceOperationLog); |
| | | try { |
| | | DeviceOperationLog deviceOperationLog = new DeviceOperationLog(); |
| | | deviceOperationLog.setUserId(userId); |
| | | deviceOperationLog.setUserName(UserName); |
| | | deviceOperationLog.setOperation(operation); |
| | | deviceOperationLog.setContent(content); |
| | | this.save(deviceOperationLog); |
| | | } catch (Exception e) { |
| | | System.out.println("存储操作帧失败,数据异常"); |
| | | } |
| | | } |
| | | |
| | | public List<String> operationList(){ |
| | | List<String> operationList= deviceOperationLogMapper.operationList(); |
| | | return operationList; |
| | | } |
| | | |
| | | |