package com.sandu.ximon.admin.utils;
|
|
import com.sandu.common.util.SpringContextHolder;
|
import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
|
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
|
import com.sandu.ximon.admin.service.DeviceOperationLogService;
|
import com.sandu.ximon.admin.service.InnerFrameDataService;
|
import com.sandu.ximon.dao.domain.Pole;
|
import com.sandu.ximon.dao.mapper.PoleBindingMapper;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @author ZZQ
|
* @date 2022/5/13 15:06
|
*/
|
public class StoreOperationRecordsUtils {
|
/**
|
* 保存硬件控制帧数据
|
*
|
* @param mac
|
* @param innerFrameTpye
|
* @param a5Frame
|
* @param commonFrame
|
*/
|
public static void storeInnerFrameData(String mac, String innerFrameTpye, A5Frame a5Frame, CommonFrame commonFrame) {
|
String reportInnerFrame = "";
|
if (commonFrame != null) {
|
reportInnerFrame = commonFrame.getConnectType() + commonFrame.getFunctionCode() + commonFrame.getOrderType() + commonFrame.getPayloadLength() + commonFrame.getPayload();
|
}
|
String requstInnerFrame = a5Frame.getConnectType() + a5Frame.getFunctionCode() + a5Frame.getOrderType() + a5Frame.getPayloadLength() + a5Frame.getPayload();
|
String syncType;
|
if ("FE".equals(a5Frame.getConnectType())) {
|
syncType = "同步";
|
} else {
|
syncType = "异步";
|
}
|
SpringContextHolder.getBean(InnerFrameDataService.class).storeInnerFrameData(mac, innerFrameTpye, syncType, requstInnerFrame, reportInnerFrame);
|
}
|
|
/**
|
* 保存操作数据
|
*
|
* @param deviceCodeList
|
* @param deviceName
|
* @param operation
|
* @param content
|
*/
|
public static void storeOperationData(List deviceCodeList, String deviceName, String operation, String content) {
|
if (deviceCodeList == null) {
|
deviceCodeList = new ArrayList<>();
|
}
|
List<String> poleCodeList = new ArrayList<>();
|
for (Object str : deviceCodeList) {
|
Pole pole = SpringContextHolder.getBean(PoleBindingMapper.class).getPoleByBinding(null, String.valueOf(str), null);
|
if (pole != null) {
|
poleCodeList.add(pole.getDeviceCode());
|
} else {
|
poleCodeList.add("");
|
}
|
}
|
SpringContextHolder.getBean(DeviceOperationLogService.class)
|
.saveDeviceOperationLog(deviceCodeList.toString(), deviceName, operation, content, poleCodeList.toString());
|
}
|
}
|