2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-05-13 5186ebb4be5de7d857809c191c1ebbe4f2da4019
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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;
 
/**
 * @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 deviceCode
     * @param deviceName
     * @param operation
     * @param content
     * @param poleCode
     */
    public static void storeOperationData(String deviceCode, String deviceName, String operation, String content, String poleCode) {
        SpringContextHolder.getBean(DeviceOperationLogService.class).saveDeviceOperationLog(deviceCode, deviceName, operation, content, poleCode);
    }
}