Code.java 2.57 KB
package com.viontech.integration.jiaoguansuo.entity;

import cn.hutool.core.util.XmlUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * .
 *
 * @author 谢明辉
 * @date 2022/2/23
 */

@SuppressWarnings("ALL")
public enum Code {
    C_1003("大货车禁行","开启"),
    C_1005("逆行","启用"),
    C_1006("压导流带","启用算法"),
    C_1007("跨线变道","启用"),
    C_1009("异常停车","启用"),
    C_1012("超速","启用"),
    C_1013("隧道车灯","启用"),
    C_1016("车辆超限","启用"),
    C_1017("货车载人","启用"),

    C_0001("行人上高速事件","启用"),
    C_0005("拥堵检测","启用"),
    C_0006("事故","启用"),
    C_0007("隧道烟雾","启用"),
    C_0009("路面湿滑","启用"),
    C_0011("道路破损","启用"){
        @Override
        public String modifyConfig(String xml) {
            Document document = XmlUtil.parseXml(xml);
            Element element = XmlUtil.getElementByXPath("//root//功能配置//抓拍参数配置//路口电警", document);
            Element zongzhi = XmlUtil.appendChild(element, "综治");
            Element paramNode = XmlUtil.appendChild(zongzhi, paramName);
            Element open = XmlUtil.appendChild(paramNode, openName);
            XmlUtil.appendText(open, "1");
            return XmlUtil.toStr(document);
        }
    },
    C_0013("抛洒物检测","启用"),
    C_0015("施工占道","启用"){
        @Override
        public String modifyConfig(String xml) {
            Document document = XmlUtil.parseXml(xml);
            Element element = XmlUtil.getElementByXPath("//root//功能配置//抓拍参数配置//路口电警", document);
            Element zongzhi = XmlUtil.appendChild(element, "综治");
            Element paramNode = XmlUtil.appendChild(zongzhi, paramName);
            Element open = XmlUtil.appendChild(paramNode, openName);
            XmlUtil.appendText(open, "1");
            return XmlUtil.toStr(document);
        }
    };

    public String paramName;
    public String openName;

    Code(String paramName, String openName) {
        this.paramName = paramName;
        this.openName = openName;
    }

    public String modifyConfig(String xml) {
        Document document = XmlUtil.parseXml(xml);
        Element element = XmlUtil.getElementByXPath("//root//功能配置//抓拍参数配置//路口电警", document);
        Element paramNode = XmlUtil.appendChild(element, paramName);
        Element open = XmlUtil.appendChild(paramNode, openName);
        XmlUtil.appendText(open, "1");
        return XmlUtil.toStr(document);
    }
}