package com.xzzn.ems.service.impl;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xzzn.common.constant.RedisKeyConstants;
import com.xzzn.common.core.redis.RedisCache;
import com.xzzn.common.enums.*;
import com.xzzn.common.utils.DateUtils;
import com.xzzn.common.utils.MapUtils;
import com.xzzn.common.utils.StringUtils;
import com.xzzn.ems.domain.*;
import com.xzzn.ems.mapper.EmsClusterAlarmDataMapper;
import com.xzzn.ems.mapper.EmsCoolingAlarmDataMapper;
import com.xzzn.ems.mapper.EmsPcsAlarmDataMapper;
import com.xzzn.ems.mapper.EmsStackAlarmDataMapper;
import com.xzzn.ems.service.IEmsAlarmRecordsService;
import com.xzzn.ems.service.IFXXAlarmDataProcessService;
import com.xzzn.ems.utils.AbstractBatteryDataProcessor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class FXXAlarmDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXAlarmDataProcessService {
    private static final Log log = LogFactory.getLog(FXXAlarmDataProcessServiceImpl.class);
    private static final String SITE_ID = "021_FXX_01";

    @Autowired
    private RedisCache redisCache;

    @Autowired
    private IEmsAlarmRecordsService iEmsAlarmRecordsService;
    @Autowired
    private EmsCoolingAlarmDataMapper emsCoolingAlarmDataMapper;
    @Autowired
    private EmsStackAlarmDataMapper emsStackAlarmDataMapper;
    @Autowired
    private EmsClusterAlarmDataMapper emsClusterAlarmDataMapper;
    @Autowired
    private EmsPcsAlarmDataMapper emsPcsAlarmDataMapper;

    // 构造方法（调用父类构造）
    public FXXAlarmDataProcessServiceImpl(ObjectMapper objectMapper) {
        super(objectMapper);
    }

    @Override
    public void handleFxAlarmData(String message) {
        JSONArray arraylist = JSONArray.parseArray(message);

        // 获取redis缓存-告警信息
        Map<String, EmsAlarmMatchData> alarmMatchInfo= redisCache.getCacheObject(RedisKeyConstants.ALARM_MATCH_INFO);

        for (int i = 0; i < arraylist.size(); i++) {
            JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString());

            String deviceId = obj.get("Device").toString();
            String jsonData = obj.get("Data").toString();
            Long timestamp = Long.valueOf(obj.get("timestamp").toString());
            Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp);

            log.info("deviceId:" + deviceId);
            String deviceCategory = "";
            if (deviceId.contains("ZSLQ")) {
                coolingDataProcess(deviceId, jsonData, dataUpdateTime);
            } else if (deviceId.contains("BMSD")) {
                deviceCategory = DeviceCategory.STACK.getCode();
                stackDataProcess(deviceId, jsonData, dataUpdateTime);
            } else if (deviceId.contains("BMSC")) {
                deviceCategory = DeviceCategory.CLUSTER.getCode();
                clusterDataProcess(deviceId, jsonData, dataUpdateTime);
            } else if (deviceId.contains("PCS")) {
                deviceCategory = DeviceCategory.PCS.getCode();
                pcsDataProcess(deviceId, jsonData, dataUpdateTime);
            }
            if (StringUtils.isEmpty(deviceCategory)) {
                // 处理告警信息
                alarmDataProcess(deviceId, jsonData, alarmMatchInfo, deviceCategory);
            }
        }
    }

    private void pcsDataProcess(String deviceId, String jsonData, Date dataUpdateTime) {
        //中水冷却
        Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {
        });
        EmsPcsAlarmData pcsAlarmData = new EmsPcsAlarmData();
        // 更新时间
        pcsAlarmData.setDataTimestamp(dataUpdateTime);

        // 告警字段
        pcsAlarmData.setYljzyc(MapUtils.getInteger(obj, "YLJZYC"));
        pcsAlarmData.setZlkgSmyc(MapUtils.getInteger(obj, "ZLKGSMYC"));
        pcsAlarmData.setJlkgSmyc(MapUtils.getInteger(obj, "JLKGSMYC"));
        pcsAlarmData.setZlfjsmyc(MapUtils.getInteger(obj, "ZLFJSMYC"));
        pcsAlarmData.setJlfjsmyc(MapUtils.getInteger(obj, "JLFJSMYC"));
        pcsAlarmData.setGjz2(MapUtils.getInteger(obj, "GJZ2"));
        pcsAlarmData.setGzz2(MapUtils.getInteger(obj, "GZZ2"));
        pcsAlarmData.setSrqgwgj(MapUtils.getInteger(obj, "SRQGWGJ"));
        pcsAlarmData.setDgfjyc(MapUtils.getInteger(obj, "DGFJYC"));
        pcsAlarmData.setBmsgj(MapUtils.getInteger(obj, "BMSGJ"));
        pcsAlarmData.setBmsdj(MapUtils.getInteger(obj, "BMSDJ"));
        pcsAlarmData.setBmsjf(MapUtils.getInteger(obj, "BMSJF"));
        pcsAlarmData.setBmsjc(MapUtils.getInteger(obj, "BMSJC"));
        pcsAlarmData.setBmsgjdyc(MapUtils.getInteger(obj, "BMSGJDYC"));
        pcsAlarmData.setBmstxyc(MapUtils.getInteger(obj, "BMSTXYC"));
        pcsAlarmData.setBmsxtgz(MapUtils.getInteger(obj, "BMSXTGZ"));
        pcsAlarmData.setZldhmktxyc(MapUtils.getInteger(obj, "ZLDHMKTXYC"));
        pcsAlarmData.setGzgJ(MapUtils.getInteger(obj, "GZGJ"));
        pcsAlarmData.setDcdybfhcdtj(MapUtils.getInteger(obj, "DCDYBFHCDTJ"));
        pcsAlarmData.setDcfj(MapUtils.getInteger(obj, "DCFJ"));
        pcsAlarmData.setWbfjyc(MapUtils.getInteger(obj, "WBFJYC"));
        pcsAlarmData.setDcdygj(MapUtils.getInteger(obj, "DCDYGJ"));
        pcsAlarmData.setDczzqy(MapUtils.getInteger(obj, "DCZZQY"));
        pcsAlarmData.setZlbxsyc(MapUtils.getInteger(obj, "ZLBXSYC"));
        pcsAlarmData.setNbfjyc(MapUtils.getInteger(obj, "NBFJYC"));
        pcsAlarmData.setDlbh(MapUtils.getInteger(obj, "DLBH"));
        pcsAlarmData.setGzbh(MapUtils.getInteger(obj, "GZBH"));
        pcsAlarmData.setScdybfhlwtj(MapUtils.getInteger(obj, "SCDYBFHLWTJ"));
        pcsAlarmData.setScdyyc(MapUtils.getInteger(obj, "SCDYYC"));
        pcsAlarmData.setZlgl(MapUtils.getInteger(obj, "ZLGL"));
        pcsAlarmData.setDcqzqy(MapUtils.getInteger(obj, "DCQZQY"));
        pcsAlarmData.setDcgy(MapUtils.getInteger(obj, "DCGY"));
        pcsAlarmData.setGlmkgwgJ(MapUtils.getInteger(obj, "GLMKGWGJ"));
        pcsAlarmData.setDwgqpdjgj(MapUtils.getInteger(obj, "DWGQPDJGJ"));
        pcsAlarmData.setKkhrqyc(MapUtils.getInteger(obj, "KKHRQYC"));
        pcsAlarmData.setBmsjt(MapUtils.getInteger(obj, "BMSJT"));
        pcsAlarmData.setBwjdvc(MapUtils.getInteger(obj, "BWJDYC"));
        pcsAlarmData.setJljdvc(MapUtils.getInteger(obj, "JLJDYC"));
        pcsAlarmData.setFjjdvc(MapUtils.getInteger(obj, "FJJDYC"));
        pcsAlarmData.setZjjdvc(MapUtils.getInteger(obj, "ZJJDYC"));
        pcsAlarmData.setDgwdkgwc(MapUtils.getInteger(obj, "DGWDKGYC"));
        pcsAlarmData.setFybyqwdkgwc(MapUtils.getInteger(obj, "FYBYQWDKGYC"));
        pcsAlarmData.setWbwdkgwc(MapUtils.getInteger(obj, "WBWDKGYC"));
        pcsAlarmData.setSrqwdkgwc(MapUtils.getInteger(obj, "SRQWDKGYC"));
        pcsAlarmData.setZlfjyc(MapUtils.getInteger(obj, "ZLFJYC"));
        pcsAlarmData.setGdycyyx(MapUtils.getInteger(obj, "GDYCYYX"));
        pcsAlarmData.setDdycyyx(MapUtils.getInteger(obj, "DDYCYYX"));
        pcsAlarmData.setDwdybphgj(MapUtils.getInteger(obj, "DWDYBPHGJ"));
        pcsAlarmData.setXtcsbpp(MapUtils.getInteger(obj, "XTCSBPP"));
        pcsAlarmData.setZlblmsszcw(MapUtils.getInteger(obj, "ZLBLMSSZCW"));
        pcsAlarmData.setGjz(MapUtils.getInteger(obj, "GJZ"));
        pcsAlarmData.setGzz(MapUtils.getInteger(obj, "GZZ"));
        pcsAlarmData.setYctxyc(MapUtils.getInteger(obj, "YCTXYC"));
        pcsAlarmData.setHmi485txyc(MapUtils.getInteger(obj, "HMI485TXYC"));
        pcsAlarmData.setJxszcw(MapUtils.getInteger(obj, "JXSZCW"));
        pcsAlarmData.setHmictxyc(MapUtils.getInteger(obj, "HMICTXYC"));
        pcsAlarmData.setBjtxyc(MapUtils.getInteger(obj, "BJTXYC"));
        pcsAlarmData.setYwgj(MapUtils.getInteger(obj, "YWGJ"));
        pcsAlarmData.setZlzjcqyc(MapUtils.getInteger(obj, "ZLZJCQYC"));
        pcsAlarmData.setLxgl(MapUtils.getInteger(obj, "LXGL"));
        pcsAlarmData.setZldhyc(MapUtils.getInteger(obj, "ZLDHYC"));
        pcsAlarmData.setTbctxvc(MapUtils.getInteger(obj, "TBCTXYC"));
        pcsAlarmData.setBjtxxyc(MapUtils.getInteger(obj, "BJTXXYC"));
        pcsAlarmData.setXxgxctxvc(MapUtils.getInteger(obj, "XXGXCTXYC"));
        pcsAlarmData.setIdct(MapUtils.getInteger(obj, "IDCT"));
        pcsAlarmData.setQdyc(MapUtils.getInteger(obj, "QDYC"));
        pcsAlarmData.setNbyjgl(MapUtils.getInteger(obj, "NBYJGL"));
        pcsAlarmData.setZndbtxyc(MapUtils.getInteger(obj, "ZNDBTXYC"));
        pcsAlarmData.setZlflqyc(MapUtils.getInteger(obj, "ZLFLQYC"));
        pcsAlarmData.setSxyc(MapUtils.getInteger(obj, "SXYC"));
        pcsAlarmData.setMjgj(MapUtils.getInteger(obj, "MJGJ"));
        pcsAlarmData.setLpjzyc(MapUtils.getInteger(obj, "LPJZYC"));
        pcsAlarmData.setMxdlgl(MapUtils.getInteger(obj, "MXDLGL"));
        pcsAlarmData.setMxdbyfhkjtj(MapUtils.getInteger(obj, "MXDYBFHKJTJ"));
        pcsAlarmData.setWbjt(MapUtils.getInteger(obj, "WBJT"));
        pcsAlarmData.setNbjt(MapUtils.getInteger(obj, "NBJT"));
        pcsAlarmData.setJlflqyc(MapUtils.getInteger(obj, "JLFLQYC"));
        pcsAlarmData.setRjhjyc(MapUtils.getInteger(obj, "RJHJYC"));
        pcsAlarmData.setJlrqdyc(MapUtils.getInteger(obj, "JLRQDYC"));
        pcsAlarmData.setJngw(MapUtils.getInteger(obj, "JNGW"));
        pcsAlarmData.setNbyc(MapUtils.getInteger(obj, "NBYC"));
        pcsAlarmData.setWdkgwc(MapUtils.getInteger(obj, "WDKGYC"));
        pcsAlarmData.setJlkgwc(MapUtils.getInteger(obj, "JLKGYC"));
        pcsAlarmData.setJlfjyc(MapUtils.getInteger(obj, "JLFJYC"));
        pcsAlarmData.setZlkgwc(MapUtils.getInteger(obj, "ZLKGYC"));
        pcsAlarmData.setZlrqdyc(MapUtils.getInteger(obj, "ZLRQDYC"));
        pcsAlarmData.setNbrjgl(MapUtils.getInteger(obj, "NBRJGL"));
        pcsAlarmData.setDwxxyc(MapUtils.getInteger(obj, "DWXXYC"));
        pcsAlarmData.setGlmkgw(MapUtils.getInteger(obj, "GLMKGW"));
        pcsAlarmData.setDwqpyc(MapUtils.getInteger(obj, "DWQPYC"));
        pcsAlarmData.setDwgpyc(MapUtils.getInteger(obj, "DWGPYC"));
        pcsAlarmData.setDwqyyc(MapUtils.getInteger(obj, "DWQYYC"));
        pcsAlarmData.setDwgyyc(MapUtils.getInteger(obj, "DWGYYC"));
        pcsAlarmData.setZlgv(MapUtils.getInteger(obj, "ZLGY"));
        pcsAlarmData.setJlllyc(MapUtils.getInteger(obj, "JLLDLYC"));
        pcsAlarmData.setJyzkyc(MapUtils.getInteger(obj, "JYZKYC"));
        pcsAlarmData.setGzbz(MapUtils.getInteger(obj, "GZBZ"));
        pcsAlarmData.setCreateBy("system");
        pcsAlarmData.setCreateTime(DateUtils.getNowDate());
        pcsAlarmData.setUpdateBy("system");
        pcsAlarmData.setUpdateTime(DateUtils.getNowDate());
        pcsAlarmData.setSiteId(SITE_ID);
        pcsAlarmData.setDeviceId(deviceId);
        emsPcsAlarmDataMapper.insertEmsPcsAlarmData(pcsAlarmData);
    }

    private void stackDataProcess(String deviceId, String jsonData, Date dataUpdateTime) {
        // bmsd
        Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {
        });
        EmsStackAlarmData stackAlarmData = new EmsStackAlarmData();
        // 更新时间
        stackAlarmData.setDataTimestamp(dataUpdateTime);

        // 告警字段
        stackAlarmData.setKttxsl(MapUtils.getInteger(obj, "KTTXSL"));
        stackAlarmData.setDidodi12(MapUtils.getInteger(obj, "DIDODI12"));
        stackAlarmData.setDidodi11(MapUtils.getInteger(obj, "DIDODI11"));
        stackAlarmData.setDidodi10(MapUtils.getInteger(obj, "DIDODI10"));
        stackAlarmData.setDidodi9(MapUtils.getInteger(obj, "DIDODI9"));
        stackAlarmData.setDidodi8(MapUtils.getInteger(obj, "DIDODI8"));
        stackAlarmData.setDidodi7(MapUtils.getInteger(obj, "DIDODI7"));
        stackAlarmData.setDidodi6(MapUtils.getInteger(obj, "DIDODI6"));
        stackAlarmData.setDidodi5(MapUtils.getInteger(obj, "DIDODI5"));
        stackAlarmData.setDidodi4(MapUtils.getInteger(obj, "DIDODI4"));
        stackAlarmData.setDidodi3(MapUtils.getInteger(obj, "DIDODI3"));
        stackAlarmData.setDidodi2(MapUtils.getInteger(obj, "DIDODI2"));
        stackAlarmData.setDidodi1(MapUtils.getInteger(obj, "DIDODI1"));
        stackAlarmData.setDidodi0(MapUtils.getInteger(obj, "DIDODI0"));
        stackAlarmData.setWdcjsl(MapUtils.getInteger(obj, "WDCJSL"));
        stackAlarmData.setDycjsl(MapUtils.getInteger(obj, "DYCJSL"));
        stackAlarmData.setDnmkdyqyyzgjhz(MapUtils.getInteger(obj, "DNMKDYQYYZGJHZ"));
        stackAlarmData.setDnmkdyqyzdgjhz(MapUtils.getInteger(obj, "DNMKDYQYZDGJHZ"));
        stackAlarmData.setDnmkdyqyqwgjhz(MapUtils.getInteger(obj, "DNMKDYQYQWGJHZ"));
        stackAlarmData.setDnmkdygyyzgjhz(MapUtils.getInteger(obj, "DNMKDYGYYZGJHZ"));
        stackAlarmData.setDnmkdygyzdgjhz(MapUtils.getInteger(obj, "DNMKDYGYZDGJHZ"));
        stackAlarmData.setDnmkdygyqwgjhz(MapUtils.getInteger(obj, "DNMKDYGYQWGJHZ"));
        stackAlarmData.setDngdzgwzzdgjhz(MapUtils.getInteger(obj, "DNGDZGWZZDGJHZ"));
        stackAlarmData.setDngdzgwzdgjhz(MapUtils.getInteger(obj, "DNGDZGWZDGJHZ"));
        stackAlarmData.setDngdzgwqwgjhz(MapUtils.getInteger(obj, "DNGDZGWQWGJHZ"));
        stackAlarmData.setYl8(MapUtils.getInteger(obj, "YL8"));
        stackAlarmData.setYl7(MapUtils.getInteger(obj, "YL7"));
        stackAlarmData.setYl6(MapUtils.getInteger(obj, "YL6"));
        stackAlarmData.setYl5(MapUtils.getInteger(obj, "YL5"));
        stackAlarmData.setYl4(MapUtils.getInteger(obj, "YL4"));
        stackAlarmData.setYl3(MapUtils.getInteger(obj, "YL3"));
        stackAlarmData.setYl2(MapUtils.getInteger(obj, "YL2"));
        stackAlarmData.setYl1(MapUtils.getInteger(obj, "YL1"));
        stackAlarmData.setSrin3(MapUtils.getInteger(obj, "SRIN3"));
        stackAlarmData.setSrin2(MapUtils.getInteger(obj, "SRIN2"));
        stackAlarmData.setSrin1(MapUtils.getInteger(obj, "SRIN1"));
        stackAlarmData.setSrin0(MapUtils.getInteger(obj, "SRIN0"));
        stackAlarmData.setBmsxtgzhz(MapUtils.getInteger(obj, "BMSXTGZHZ"));
        stackAlarmData.setBmsxtgjhz(MapUtils.getInteger(obj, "BMSXTGJHZ"));
        stackAlarmData.setFdjz(MapUtils.getInteger(obj, "FDJZ"));
        stackAlarmData.setCdjz(MapUtils.getInteger(obj, "CDJZ"));
        stackAlarmData.setDnjcqbhyc(MapUtils.getInteger(obj, "DNJCQBHYC"));
        stackAlarmData.setDnjcqdkyc(MapUtils.getInteger(obj, "DNJCQDKYC"));
        stackAlarmData.setDngzdyyc(MapUtils.getInteger(obj, "DNGZDYYC"));
        stackAlarmData.setDngckslgjhz(MapUtils.getInteger(obj, "DNGCKSLGJHZ"));
        stackAlarmData.setDngzkslhz(MapUtils.getInteger(obj, "DNGZKSLHZ"));
        stackAlarmData.setDtsohgyzgjhz(MapUtils.getInteger(obj, "DTSOHGYZGJHZ"));
        stackAlarmData.setDtsohgzdgjhz(MapUtils.getInteger(obj, "DTSOHGZDGJHZ"));
        stackAlarmData.setDtsohgqwgjhz(MapUtils.getInteger(obj, "DTSOHGQWGJHZ"));
        stackAlarmData.setDtsohdyzgjhz(MapUtils.getInteger(obj, "DTSOHDYZGJHZ"));
        stackAlarmData.setDtsohdzdgjhz(MapUtils.getInteger(obj, "DTSOHDZDGJHZ"));
        stackAlarmData.setDtsohdqwgjhz(MapUtils.getInteger(obj, "DTSOHDQWGJHZ"));
        stackAlarmData.setDtsocgyzgjhz(MapUtils.getInteger(obj, "DTSOCGYZGJHZ"));
        stackAlarmData.setDtsocgzdgjhz(MapUtils.getInteger(obj, "DTSOCGZDGJHZ"));
        stackAlarmData.setDtsocgqwgjhz(MapUtils.getInteger(obj, "DTSOCGQWGJHZ"));
        stackAlarmData.setDtsocdyzgjhz(MapUtils.getInteger(obj, "DTSOCDYZGJHZ"));
        stackAlarmData.setDtsocdzdgjhz(MapUtils.getInteger(obj, "DTSOCDZDGJHZ"));
        stackAlarmData.setDtsocdqwgjhz(MapUtils.getInteger(obj, "DTSOCDQWGJHZ"));
        stackAlarmData.setDngdtwcyzgjhz(MapUtils.getInteger(obj, "DNGDTWCYZGJHZ"));
        stackAlarmData.setDngdtwczdgjhz(MapUtils.getInteger(obj, "DNGDTWCZDGJHZ"));
        stackAlarmData.setDngdtwcqwgjhz(MapUtils.getInteger(obj, "DNGDTWCQWGJHZ"));
        stackAlarmData.setDngdtgwyzgjhz(MapUtils.getInteger(obj, "DNGDTGWYZGJHZ"));
        stackAlarmData.setDngdtgwzdgjhz(MapUtils.getInteger(obj, "DNGDTGWZDGJHZ"));
        stackAlarmData.setDngdtgwqwgjhz(MapUtils.getInteger(obj, "DNGDTGWQWGJHZ"));
        stackAlarmData.setDngdtqwyzgjhz(MapUtils.getInteger(obj, "DNGDTQWYZGJHZ"));
        stackAlarmData.setDngdtqwzdgjhz(MapUtils.getInteger(obj, "DNGDTQWZDGJHZ"));
        stackAlarmData.setDngdtqwqwgjhz(MapUtils.getInteger(obj, "DNGDTQWQWGJHZ"));
        stackAlarmData.setDngdtycyzgjhz(MapUtils.getInteger(obj, "DNGDTYCYZGJHZ"));
        stackAlarmData.setDngdtyczdgjhz(MapUtils.getInteger(obj, "DNGDTYCZDGJHZ"));
        stackAlarmData.setDngdtycqwgjhz(MapUtils.getInteger(obj, "DNGDTYCQWGJHZ"));
        stackAlarmData.setDngdtqyyzgjhz(MapUtils.getInteger(obj, "DNGDTQYYZGJHZ"));
        stackAlarmData.setDngdtqyzdgjhz(MapUtils.getInteger(obj, "DNGDTQYZDGJHZ"));
        stackAlarmData.setDngdtqyqwgjhz(MapUtils.getInteger(obj, "DNGDTQYQWGJHZ"));
        stackAlarmData.setDngdtgyyzgjhz(MapUtils.getInteger(obj, "DNGDTGYYZGJHZ"));
        stackAlarmData.setDngdtgyzdgjhz(MapUtils.getInteger(obj, "DNGDTGYZDGJHZ"));
        stackAlarmData.setDngdtgyqwgjhz(MapUtils.getInteger(obj, "DNGDTGYQWGJHZ"));
        stackAlarmData.setDngzmkgwdzzdgjhz(MapUtils.getInteger(obj, "DNGZMKGWDZZDGJHZ"));
        stackAlarmData.setDngzmkgwdzdgjhz(MapUtils.getInteger(obj, "DNGZMKGWDZDGJHZ"));
        stackAlarmData.setDngzmkgwdqdgjhz(MapUtils.getInteger(obj, "DNGZMKGWDQDGJHZ"));
        stackAlarmData.setDngzmkqwdzzdgjhz(MapUtils.getInteger(obj, "DNGZMKQWDZZDGJHZ"));
        stackAlarmData.setDngzmkqwdzdgjhz(MapUtils.getInteger(obj, "DNGZMKQWDZDGJHZ"));
        stackAlarmData.setDngzmkqwdqdgjhz(MapUtils.getInteger(obj, "DNGZMKQWDQDGJHZ"));
        stackAlarmData.setDngzjydzdzzdgjhz(MapUtils.getInteger(obj, "DNGZJYDZDZZDGJHZ"));
        stackAlarmData.setDngzjydzdzdgjhz(MapUtils.getInteger(obj, "DNGZJYDZDZDGJHZ"));
        stackAlarmData.setDngzjydzdqdgjhz(MapUtils.getInteger(obj, "DNGZJYDZDQDGJHZ"));
        stackAlarmData.setDngzdglzzdgjhz(MapUtils.getInteger(obj, "DNGZDGLZZDGJHZ"));
        stackAlarmData.setDngzdglzdgjhz(MapUtils.getInteger(obj, "DNGZDGLZDGJHZ"));
        stackAlarmData.setDngzdglqdgjhz(MapUtils.getInteger(obj, "DNGZDGLQDGJHZ"));
        stackAlarmData.setDngzddygyzzdgjhz(MapUtils.getInteger(obj, "DNGZDDYGYZZDGJHZ"));
        stackAlarmData.setDngzddygyzdgjhz(MapUtils.getInteger(obj, "DNGZDDYGYZDGJHZ"));
        stackAlarmData.setDngzddygyqdgjhz(MapUtils.getInteger(obj, "DNGZDDYGYQDGJHZ"));
        stackAlarmData.setDngzddyqyzzdgjhz(MapUtils.getInteger(obj, "DNGZDDYQYZZDGJHZ"));
        stackAlarmData.setDngzddyqyzdgjhz(MapUtils.getInteger(obj, "DNGZDDYQYZDGJHZ"));
        stackAlarmData.setDngzddyqyqdgjhz(MapUtils.getInteger(obj, "DNGZDDYQYQDGJHZ"));
        stackAlarmData.setJfzt(MapUtils.getInteger(obj, "JFZT"));
        stackAlarmData.setJczt(MapUtils.getInteger(obj, "JCZT"));
        stackAlarmData.setBmsgzzt(MapUtils.getInteger(obj, "BMSGZZT"));

        stackAlarmData.setCreateBy("system");
        stackAlarmData.setCreateTime(DateUtils.getNowDate());
        stackAlarmData.setUpdateBy("system");
        stackAlarmData.setUpdateTime(DateUtils.getNowDate());
        stackAlarmData.setSiteId(SITE_ID);
        stackAlarmData.setDeviceId(deviceId);
        emsStackAlarmDataMapper.insertEmsStackAlarmData(stackAlarmData);
    }

    private void clusterDataProcess(String deviceId, String jsonData, Date dataUpdateTime) {
        // bmsc
        Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {
        });
        EmsClusterAlarmData clusterAlarmData = new EmsClusterAlarmData();
        // 更新时间
        clusterAlarmData.setDataTimestamp(dataUpdateTime);

        // 告警字段
        clusterAlarmData.setC1wdcjgz(MapUtils.getInteger(obj, "C1WDCJGZ"));
        clusterAlarmData.setC1dycjgz(MapUtils.getInteger(obj, "C1DYCJGZ"));
        clusterAlarmData.setC1mkdygdzzdgj(MapUtils.getInteger(obj, "C1MKDYGDZZDGJ"));
        clusterAlarmData.setC1mkdygdzdgj(MapUtils.getInteger(obj, "C1MKDYGDZDGJ"));
        clusterAlarmData.setC1mkdygdqdgj(MapUtils.getInteger(obj, "C1MKDYGDQDGJ"));
        clusterAlarmData.setC1mkdyggzzdgj(MapUtils.getInteger(obj, "C1MKDYGGZZDGJ"));
        clusterAlarmData.setC1mkdyggzdgj(MapUtils.getInteger(obj, "C1MKDYGGZDGJ"));
        clusterAlarmData.setC1mkdyggqdgj(MapUtils.getInteger(obj, "C1MKDYGGQDGJ"));
        clusterAlarmData.setC1dzwdggzzdgj(MapUtils.getInteger(obj, "C1DZWDGGZZDGJ"));
        clusterAlarmData.setC1dzwdggzdgj(MapUtils.getInteger(obj, "C1DZWDGGZDGJ"));
        clusterAlarmData.setC1dzwdggqdgj(MapUtils.getInteger(obj, "C1DZWDGGQDGJ"));
        clusterAlarmData.setC1ck40txsl(MapUtils.getInteger(obj, "C1CK40TXSL"));
        clusterAlarmData.setC1ck39txsl(MapUtils.getInteger(obj, "C1CK39TXSL"));
        clusterAlarmData.setC1ck38txsl(MapUtils.getInteger(obj, "C1CK38TXSL"));
        clusterAlarmData.setC1ck37txsl(MapUtils.getInteger(obj, "C1CK37TXSL"));
        clusterAlarmData.setC1ck36txsl(MapUtils.getInteger(obj, "C1CK36TXSL"));
        clusterAlarmData.setC1ck35txsl(MapUtils.getInteger(obj, "C1CK35TXSL"));
        clusterAlarmData.setC1ck34txsl(MapUtils.getInteger(obj, "C1CK34TXSL"));
        clusterAlarmData.setC1ck33txsl(MapUtils.getInteger(obj, "C1CK33TXSL"));
        clusterAlarmData.setC1ck32txsl(MapUtils.getInteger(obj, "C1CK32TXSL"));
        clusterAlarmData.setC1ck31txsl(MapUtils.getInteger(obj, "C1CK31TXSL"));
        clusterAlarmData.setC1ck30txsl(MapUtils.getInteger(obj, "C1CK30TXSL"));
        clusterAlarmData.setC1ck29txsl(MapUtils.getInteger(obj, "C1CK29TXSL"));
        clusterAlarmData.setC1ck28txsl(MapUtils.getInteger(obj, "C1CK28TXSL"));
        clusterAlarmData.setC1ck27txsl(MapUtils.getInteger(obj, "C1CK27TXSL"));
        clusterAlarmData.setC1ck26txsl(MapUtils.getInteger(obj, "C1CK26TXSL"));
        clusterAlarmData.setC1ck25txsl(MapUtils.getInteger(obj, "C1CK25TXSL"));
        clusterAlarmData.setC1ck24txsl(MapUtils.getInteger(obj, "C1CK24TXSL"));
        clusterAlarmData.setC1ck23txsl(MapUtils.getInteger(obj, "C1CK23TXSL"));
        clusterAlarmData.setC1ck22txsl(MapUtils.getInteger(obj, "C1CK22TXSL"));
        clusterAlarmData.setC1ck21txsl(MapUtils.getInteger(obj, "C1CK21TXSL"));
        clusterAlarmData.setC1ck20txsl(MapUtils.getInteger(obj, "C1CK20TXSL"));
        clusterAlarmData.setC1ck19txsl(MapUtils.getInteger(obj, "C1CK19TXSL"));
        clusterAlarmData.setC1ck18txsl(MapUtils.getInteger(obj, "C1CK18TXSL"));
        clusterAlarmData.setC1ck17txsl(MapUtils.getInteger(obj, "C1CK17TXSL"));
        clusterAlarmData.setC1ck16txsl(MapUtils.getInteger(obj, "C1CK16TXSL"));
        clusterAlarmData.setC1ck15txsl(MapUtils.getInteger(obj, "C1CK15TXSL"));
        clusterAlarmData.setC1ck14txsl(MapUtils.getInteger(obj, "C1CK14TXSL"));
        clusterAlarmData.setC1ck13txsl(MapUtils.getInteger(obj, "C1CK13TXSL"));
        clusterAlarmData.setC1ck12txsl(MapUtils.getInteger(obj, "C1CK12TXSL"));
        clusterAlarmData.setC1ck11txsl(MapUtils.getInteger(obj, "C1CK11TXSL"));
        clusterAlarmData.setC1ck10txsl(MapUtils.getInteger(obj, "C1CK10TXSL"));
        clusterAlarmData.setC1ck9txsl(MapUtils.getInteger(obj, "C1CK9TXSL"));
        clusterAlarmData.setC1ck8txsl(MapUtils.getInteger(obj, "C1CK8TXSL"));
        clusterAlarmData.setC1ck7txsl(MapUtils.getInteger(obj, "C1CK7TXSL"));
        clusterAlarmData.setC1ck6txsl(MapUtils.getInteger(obj, "C1CK6TXSL"));
        clusterAlarmData.setC1ck5txsl(MapUtils.getInteger(obj, "C1CK5TXSL"));
        clusterAlarmData.setC1ck4txsl(MapUtils.getInteger(obj, "C1CK4TXSL"));
        clusterAlarmData.setC1ck3txsl(MapUtils.getInteger(obj, "C1CK3TXSL"));
        clusterAlarmData.setC1ck2txsl(MapUtils.getInteger(obj, "C1CK2TXSL"));
        clusterAlarmData.setC1ck1txsl(MapUtils.getInteger(obj, "C1CK1TXSL"));
        clusterAlarmData.setC1dtwczzdgj(MapUtils.getInteger(obj, "C1DTWCZZDGJ"));
        clusterAlarmData.setC1dtwczdgj(MapUtils.getInteger(obj, "C1DTWCZDGJ"));
        clusterAlarmData.setC1dtwcqdgj(MapUtils.getInteger(obj, "C1DTWCQDGJ"));
        clusterAlarmData.setC1dtyczzdgj(MapUtils.getInteger(obj, "C1DTYCZZDGJ"));
        clusterAlarmData.setC1dtyczdgj(MapUtils.getInteger(obj, "C1DTYCZDGJ"));
        clusterAlarmData.setC1dtycqdgj(MapUtils.getInteger(obj, "C1DTYCQDGJ"));
        clusterAlarmData.setC1sohdzzdgj(MapUtils.getInteger(obj, "C1SOHDZZDGJ"));
        clusterAlarmData.setC1sohdzdgj(MapUtils.getInteger(obj, "C1SOHDZDGJ"));
        clusterAlarmData.setC1sohdqdgj(MapUtils.getInteger(obj, "C1SOHDQDGJ"));
        clusterAlarmData.setC1socgzzdgj(MapUtils.getInteger(obj, "C1SOCGZZDGJ"));
        clusterAlarmData.setC1socgzdgj(MapUtils.getInteger(obj, "C1SOCGZDGJ"));
        clusterAlarmData.setC1socdzzdgj(MapUtils.getInteger(obj, "C1SOCDZZDGJ"));
        clusterAlarmData.setC1socdzdgj(MapUtils.getInteger(obj, "C1SOCDZDGJ"));
        clusterAlarmData.setC1socdqdgj(MapUtils.getInteger(obj, "C1SOCDQDGJ"));
        clusterAlarmData.setC1dtgwzzdgj(MapUtils.getInteger(obj, "C1DTGWZZDGJ"));
        clusterAlarmData.setC1dtgwzdgj(MapUtils.getInteger(obj, "C1DTGWZDGJ"));
        clusterAlarmData.setC1dtgwqdgj(MapUtils.getInteger(obj, "C1DTGWQDGJ"));
        clusterAlarmData.setC1dtqwzzdgj(MapUtils.getInteger(obj, "C1DTQWZZDGJ"));
        clusterAlarmData.setC1dtqwzdgj(MapUtils.getInteger(obj, "C1DTQWZDGJ"));
        clusterAlarmData.setC1dtqwqdgj(MapUtils.getInteger(obj, "C1DTQWQDGJ"));
        clusterAlarmData.setC1dtgyzzdgj(MapUtils.getInteger(obj, "C1DTGYZZDGJ"));
        clusterAlarmData.setC1dtgyzdgj(MapUtils.getInteger(obj, "C1DTGYZDGJ"));
        clusterAlarmData.setC1dtgyqdgj(MapUtils.getInteger(obj, "C1DTGYQDGJ"));
        clusterAlarmData.setC1dtqyzzdgj(MapUtils.getInteger(obj, "C1DTQYZZDGJ"));
        clusterAlarmData.setC1dtqyzdgj(MapUtils.getInteger(obj, "C1DTQYZDGJ"));
        clusterAlarmData.setC1dtqyqdgj(MapUtils.getInteger(obj, "C1DTQYQDGJ"));
        clusterAlarmData.setC1ddlzzdgj(MapUtils.getInteger(obj, "C1DDLZZDGJ"));
        clusterAlarmData.setC1ddlzdgj(MapUtils.getInteger(obj, "C1DDLZDGJ"));
        clusterAlarmData.setC1ddlqdgj(MapUtils.getInteger(obj, "C1DDLQDGJ"));
        clusterAlarmData.setC1ddygyzzdgj(MapUtils.getInteger(obj, "C1DDYGYZZDGJ"));
        clusterAlarmData.setC1ddygyzdgj(MapUtils.getInteger(obj, "C1DDYGYZDGJ"));
        clusterAlarmData.setC1ddygyqdgj(MapUtils.getInteger(obj, "C1DDYGYQDGJ"));
        clusterAlarmData.setC1ddyqyzzdgj(MapUtils.getInteger(obj, "C1DDYQYZZDGJ"));
        clusterAlarmData.setC1ddyqyzdgj(MapUtils.getInteger(obj, "C1DDYQYZDGJ"));
        clusterAlarmData.setC1ddyqyqdgj(MapUtils.getInteger(obj, "C1DDYQYQDGJ"));
        clusterAlarmData.setC1zktxsl(MapUtils.getInteger(obj, "C1ZKTXSL"));
        clusterAlarmData.setC1socgqdgj(MapUtils.getInteger(obj, "C1SOCGQDGJ"));

        clusterAlarmData.setCreateBy("system");
        clusterAlarmData.setCreateTime(DateUtils.getNowDate());
        clusterAlarmData.setUpdateBy("system");
        clusterAlarmData.setUpdateTime(DateUtils.getNowDate());
        clusterAlarmData.setSiteId(SITE_ID);
        clusterAlarmData.setDeviceId(deviceId);
        emsClusterAlarmDataMapper.insertEmsClusterAlarmData(clusterAlarmData);
    }

    private void coolingDataProcess(String deviceId, String jsonData, Date dataUpdateTime) {
        //中水冷却
        Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {
        });

        EmsCoolingAlarmData coolingAlarmData = new EmsCoolingAlarmData();
        // 更新时间
        coolingAlarmData.setDataTimestamp(dataUpdateTime);

        // 告警字段
        // 从Map中获取值并转为Integer，适配tinyint字段
        coolingAlarmData.setLsjyx(MapUtils.getInteger(obj, "LSJYX"));
        coolingAlarmData.setPqdcfyx(MapUtils.getInteger(obj, "PQDCFYX"));
        coolingAlarmData.setDjrq2yx(MapUtils.getInteger(obj, "DJRQ2YX"));
        coolingAlarmData.setDjrq1yx(MapUtils.getInteger(obj, "DJRQ1YX"));
        coolingAlarmData.setBqbyx(MapUtils.getInteger(obj, "BQBYX"));
        coolingAlarmData.setBsbyx(MapUtils.getInteger(obj, "BSBYX"));
        coolingAlarmData.setZxhbyx(MapUtils.getInteger(obj, "ZXHBYX")); // 此处不再报错
        coolingAlarmData.setSltzgz(MapUtils.getInteger(obj, "SLTZGZ"));
        coolingAlarmData.setSlzhyj(MapUtils.getInteger(obj, "SLZHYJ"));
        coolingAlarmData.setSlxtyctzxh(MapUtils.getInteger(obj, "SLXTYCTZXH"));
        coolingAlarmData.setSlxtycqdxh(MapUtils.getInteger(obj, "SLXTYCQDXH"));
        coolingAlarmData.setSlxtyckz(MapUtils.getInteger(obj, "SLXTYCKZ"));
        coolingAlarmData.setSlxtbdkz(MapUtils.getInteger(obj, "SLXTBDKZ"));
        coolingAlarmData.setSlxtzdms(MapUtils.getInteger(obj, "SLXTZDMS"));
        coolingAlarmData.setSlxtsdms(MapUtils.getInteger(obj, "SLXTSDMS"));
        coolingAlarmData.setHsylcdyj(MapUtils.getInteger(obj, "HSYLCDYJ"));
        coolingAlarmData.setHsyldyj(MapUtils.getInteger(obj, "HSYLDYJ"));
        coolingAlarmData.setGsylcgyj(MapUtils.getInteger(obj, "GSYLCGYJ"));
        coolingAlarmData.setGsylgyj(MapUtils.getInteger(obj, "GSYLGYJ"));
        coolingAlarmData.setGsylcdyj(MapUtils.getInteger(obj, "GSYLCDYJ"));
        coolingAlarmData.setGsyldyj(MapUtils.getInteger(obj, "GSYLDYJ"));
        coolingAlarmData.setHcgywg(MapUtils.getInteger(obj, "HCGYWG"));
        coolingAlarmData.setHcgywcdtz(MapUtils.getInteger(obj, "HCGYWCDTZ"));
        coolingAlarmData.setHcgywd(MapUtils.getInteger(obj, "HCGYWD"));
        coolingAlarmData.setHcgylg(MapUtils.getInteger(obj, "HCGYLG"));
        coolingAlarmData.setHcgyld(MapUtils.getInteger(obj, "HCGYLD"));
        coolingAlarmData.setLysylgyj(MapUtils.getInteger(obj, "LYSYLGYJ"));
        coolingAlarmData.setLysyldyj(MapUtils.getInteger(obj, "LYSYLDYJ"));
        coolingAlarmData.setHswdcgyj(MapUtils.getInteger(obj, "HSWDCGYJ"));
        coolingAlarmData.setHswdgyj(MapUtils.getInteger(obj, "HSWDGYJ"));
        coolingAlarmData.setGswdcgtz(MapUtils.getInteger(obj, "GSWDCGTZ"));
        coolingAlarmData.setGswdgyj(MapUtils.getInteger(obj, "GSWDGYJ"));
        coolingAlarmData.setGswddyj(MapUtils.getInteger(obj, "GSWDDYJ"));
        coolingAlarmData.setDdf2gz(MapUtils.getInteger(obj, "DDF2GZ"));
        coolingAlarmData.setDdf1gz(MapUtils.getInteger(obj, "DDF1GZ"));
        coolingAlarmData.setLyswdbsqyJ(MapUtils.getInteger(obj, "LYSWDBSQYJ"));
        coolingAlarmData.setHsylbsqyJ(MapUtils.getInteger(obj, "HSYLBSQYJ"));
        coolingAlarmData.setGsylbsqyJ(MapUtils.getInteger(obj, "GSYLBSQYJ"));
        coolingAlarmData.setHswdbsqyJ(MapUtils.getInteger(obj, "HSWDBSQYJ"));
        coolingAlarmData.setGswdbsqgztz(MapUtils.getInteger(obj, "GSWDBSQGZTZ"));
        coolingAlarmData.setLsjgz(MapUtils.getInteger(obj, "LSJGZ"));
        coolingAlarmData.setDjrq2gz(MapUtils.getInteger(obj, "DJRQ2GZ"));
        coolingAlarmData.setDjrq1gz(MapUtils.getInteger(obj, "DJRQ1GZ"));
        coolingAlarmData.setBqbgz(MapUtils.getInteger(obj, "BQBGZ"));
        coolingAlarmData.setBsbgz(MapUtils.getInteger(obj, "BSBGZ"));
        coolingAlarmData.setXhbgz(MapUtils.getInteger(obj, "XHBGZ"));
        coolingAlarmData.setZdygz(MapUtils.getInteger(obj, "ZDYGZ"));

        coolingAlarmData.setCreateBy("system");
        coolingAlarmData.setCreateTime(DateUtils.getNowDate());
        coolingAlarmData.setUpdateBy("system");
        coolingAlarmData.setUpdateTime(DateUtils.getNowDate());
        coolingAlarmData.setSiteId(SITE_ID);
        coolingAlarmData.setDeviceId(deviceId);
        emsCoolingAlarmDataMapper.insertEmsCoolingAlarmData(coolingAlarmData);
    }

    @Override
    public void processBatch(List<EmsBatteryData> batchData) {
        super.processBatch(batchData);
    }

    private void alarmDataProcess(String deviceId, String jsonData,
                                  Map<String, EmsAlarmMatchData> alarmInfoData, String category) {
        Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {
        });

        String redisKey = RedisKeyConstants.LATEST_ALARM_RECORD + "_" + SITE_ID +"_" + deviceId;
        // 获取redis里面的当前有效告警遍历添加到已存在告警key里面
        Map<String, Object> currentAlarm = redisCache.getCacheMap(redisKey);
        final Set<String> currentAlarmKeys = new HashSet<>();
        if (currentAlarm != null && !currentAlarm.isEmpty()) {
            currentAlarm.keySet().stream()
                    .filter(Objects::nonNull)
                    .map(Object::toString)
                    .forEach(currentAlarmKeys::add);
        }

        // 结合同步数据，筛选簇需要更新的告警信息
        List<String> needUpdateKeys = obj.entrySet().stream()
                .filter(entry -> {
                        Object valueObj = entry.getValue();
                        if (valueObj == null) {
                            return false;
                        }
                        int value = Integer.parseInt(valueObj.toString());
                        return value == 0 && currentAlarmKeys.contains(entry.getKey());
                })
                .map(Map.Entry::getKey)
                .collect(Collectors.toList());

        // 批量查询数据库-需要更新的数据
        Map<String, EmsAlarmRecords> needUpdateMap = new HashMap<>();
        if (!needUpdateKeys.isEmpty()) {
             List<EmsAlarmRecords> records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys,SITE_ID, deviceId);
            // 转为Map便于快速获取
            needUpdateMap = records.stream()
                    .collect(Collectors.toMap(
                            EmsAlarmRecords::getAlarmPoint,
                            record -> record
                    ));
        }


        List<EmsAlarmRecords> saveOrUpdateList = new ArrayList<>();
        List<EmsAlarmRecords> newAddRecordList = new ArrayList<>();
        List<String> toRemoveFromRedis = new ArrayList<>();

        // 遍历数据map
        for (Map.Entry<String, Object> entry : obj.entrySet()) {
            String key = entry.getKey();
            Integer value = (Integer) entry.getValue();
            Boolean isCurrentAlarm = currentAlarmKeys.contains(key);

            // 值为 1且不在当前告警里面 - 新增告警
            if (value == 1 && !isCurrentAlarm) {
                String matchRedisKey = category + "_" + key;
                Object cacheObj = alarmInfoData.get(matchRedisKey);
                if (cacheObj == null) {
                    // 处理空数据逻辑
                    return;
                }
                EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class);
                EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(deviceId,matchInfo);
                saveOrUpdateList.add(emsAlarmRecord);
                newAddRecordList.add(emsAlarmRecord);
            } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理
                EmsAlarmRecords existingAlarm = needUpdateMap.get(key);
                if (existingAlarm != null) {
                    existingAlarm.setStatus(AlarmStatus.DONE.getCode());
                    existingAlarm.setUpdateTime(new Date());
                    existingAlarm.setAlarmEndTime(new Date());
                    saveOrUpdateList.add(existingAlarm);
                    toRemoveFromRedis.add(key);
                }
            }
        }

        // 批量处理插入和更新操作
        if (saveOrUpdateList != null && saveOrUpdateList.size() > 0) {
            iEmsAlarmRecordsService.batchProcessAlarmRecords(saveOrUpdateList);
        }
        // 已处理的从redis里面删除
        if (!toRemoveFromRedis.isEmpty()) {
            redisCache.deleteAllCacheMapValue(RedisKeyConstants.LATEST_ALARM_RECORD + SITE_ID,toRemoveFromRedis.toArray());
        }
        // 批量添加新增的告警到Redis
        Map<String, EmsAlarmRecords> newAlarms = newAddRecordList.stream()
                .filter(a -> !AlarmStatus.DONE.getCode().equals(a.getStatus()))
                .collect(Collectors.toMap(EmsAlarmRecords::getAlarmPoint, a -> a));
        if (!newAlarms.isEmpty()) {
            // 本次新增的放入redis
            redisCache.setAllCacheMapValue(redisKey, newAlarms);
        }
    }

    private EmsAlarmRecords convertAlarmRecord(String deviceId, EmsAlarmMatchData matchInfo) {
        EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords();
        emsAlarmRecords.setSiteId(SITE_ID);
        emsAlarmRecords.setDeviceId(deviceId);
        emsAlarmRecords.setDeviceType(DeviceType.TCP.toString());
        emsAlarmRecords.setAlarmLevel(AlarmLevelStatus.GENERAL.getCode());
        emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode());
        emsAlarmRecords.setAlarmStartTime(DateUtils.getNowDate());
        emsAlarmRecords.setCreateTime(DateUtils.getNowDate());
        emsAlarmRecords.setCreateBy("system");
        emsAlarmRecords.setUpdateTime(DateUtils.getNowDate());
        emsAlarmRecords.setUpdateBy("system");

        if (matchInfo != null) {
            emsAlarmRecords.setAlarmPoint(matchInfo.getPoint());
            emsAlarmRecords.setAlarmContent(matchInfo.getAlarmDescription());
        }
        return emsAlarmRecords;
    }

    // 空数据不处理
    private boolean checkJsonDataEmpty(String jsonData) {
        boolean flag = false;
        try {
            if (StringUtils.isEmpty(jsonData)) {
                flag = true;
            }
            JsonNode jsonNode  = objectMapper.readTree(jsonData);
            // 判断是否为空对象（{}）
            if (jsonNode.isObject() && jsonNode.isEmpty()) {
                flag  = true ;
            }
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        return flag;
    }
}
