Newer
Older
sink / src / main / java / org / flume / alarm / restful / AlarmDataCenterUtilDTO.java
zhout on 2 Mar 2022 6 KB first commit
package org.flume.alarm.restful;


import com.google.gson.GsonBuilder;
import net.sf.json.JSONObject;
import org.flume.alarm.core.util.DateUtils;
import org.flume.alarm.core.util.MD5Utils;
import org.flume.alarm.core.util.StringUtils;
import org.flume.alarm.util.Configure;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class AlarmDataCenterUtilDTO {

    public static Map<String, String> devTypeCodeMap = new HashMap<String, String>();


    private String appCode;
    private String sourceEventId;
    private String eventSource;
    private String longitude;
    private String latitude;
    private String eventAddress;
    private String eventContent;
    private String pType;
    private String type;
    private String typeTree;
    private String eventLv;
    private String eventTime;
    private String reportTime;
    private String reportName;
    private String reportPhone;

    private String reportSex;
    private String isSecret;
    private String isOpen;

    private String keyword;
    private String remark;
    private String eventName;
    private String flowId;
    private String attachments;


    public String getFlowId() {
        return flowId;
    }

    public void setFlowId(String flowId) {
        this.flowId = flowId;
    }

    public String getAppCode() {
        return appCode;
    }

    public void setAppCode(String appCode) {
        this.appCode = appCode;
    }

    public String getSourceEventId() {
        return sourceEventId;
    }

    public void setSourceEventId(String sourceEventId) {
        this.sourceEventId = sourceEventId;
    }

    public String getEventSource() {
        return eventSource;
    }

    public void setEventSource(String eventSource) {
        this.eventSource = eventSource;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getEventAddress() {
        return eventAddress;
    }

    public void setEventAddress(String eventAddress) {
        this.eventAddress = eventAddress;
    }

    public String getEventContent() {
        return eventContent;
    }

    public void setEventContent(String eventContent) {
        this.eventContent = eventContent;
    }

    public String getpType() {
        return pType;
    }

    public void setpType(String pType) {
        this.pType = pType;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeTree() {
        return typeTree;
    }

    public void setTypeTree(String typeTree) {
        this.typeTree = typeTree;
    }

    public String getEventLv() {
        return eventLv;
    }

    public void setEventLv(String eventLv) {
        this.eventLv = eventLv;
    }

    public String getEventTime() {
        return eventTime;
    }

    public void setEventTime(String eventTime) {
        this.eventTime = eventTime;
    }

    public String getReportTime() {
        return reportTime;
    }

    public void setReportTime(String reportTime) {
        this.reportTime = reportTime;
    }

    public String getReportName() {
        return reportName;
    }

    public void setReportName(String reportName) {
        this.reportName = reportName;
    }

    public String getReportPhone() {
        return reportPhone;
    }

    public void setReportPhone(String reportPhone) {
        this.reportPhone = reportPhone;
    }

    public String getReportSex() {
        return reportSex;
    }

    public void setReportSex(String reportSex) {
        this.reportSex = reportSex;
    }

    public String getIsSecret() {
        return isSecret;
    }

    public void setIsSecret(String isSecret) {
        this.isSecret = isSecret;
    }

    public String getIsOpen() {
        return isOpen;
    }

    public void setIsOpen(String isOpen) {
        this.isOpen = isOpen;
    }


    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }


    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        String randomString = uuid.toString().replace("-", "").toUpperCase();
        return randomString;
    }


    public AlarmDataCenterUtilDTO() {
    }


    public AlarmDataCenterUtilDTO(String externalEventId,
                                  String eventAddress, String pType,
                                  String type, String eventTime,
                                  String eventLv, String reportSex,
                                  String isSecret, String isOpen,
                                  String keyword, String remark,
                                  String longitude, String latitude,
                                  String eventContent, String eventName) {
        this.appCode = "RongJiang";
        this.sourceEventId = externalEventId;
        this.reportName = "区运行调度指挥中心";
        this.eventAddress = eventAddress;
        this.reportPhone = "13899248765";
        this.eventLv = eventLv;
        this.reportSex = reportSex;
        this.isSecret = isSecret;
        this.isOpen = isOpen;
        this.eventSource = "智慧管网";
        this.keyword = keyword;
        this.remark = remark;
        this.longitude = longitude;
        this.latitude = latitude;
        this.eventContent = eventContent;
        this.pType = pType;
        this.type = type;
        this.typeTree = "城市管理/安全隐患/其他";
        this.eventName = eventName;
        this.flowId = "";
        this.reportTime = DateUtils.sdf4.format(new Date());
        this.eventTime = eventTime;
    }

    public static String sendMsg(String url, AlarmDataCenterUtilDTO msg) {
        String resultMsg = "";
        try {
            Map<String, Object> jsonMap = new HashMap<String, Object>();
            jsonMap.put("data", msg);
            resultMsg = HttpClientUtils.post(url, new GsonBuilder().create().toJson(msg));
            System.out.println("****************************" + resultMsg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultMsg;
    }

}