package com.zkqy.execution.produce.dispersed.entity.runbpm;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

/**
 * 节点运行中间表
 *
 * @author hanzihang
 * @date 2023/11/23
 */
public class BpmRunNodeVo {

    //  当前任务流程编码
    private String taskProcessKey;

    // 当前执行节点的唯一编码
    private String taskNodeKey;

    // 当前节点的下个节点的编码
    private String nextNodeKey;

    // 当前节点绑定的脚本名称
    private String implementationName;

    // 当前节点对应的流程文件内容
    private String taskProcessXmlContent;

    // 当前节点触发时填写的表单信息
    private Map<String, Object> formDataMap;

    // 当前节点绑定表单的表名称
    private String tableName;

    public String getTaskProcessKey() {
        return taskProcessKey;
    }

    public void setTaskProcessKey(String taskProcessKey) {
        this.taskProcessKey = taskProcessKey;
    }

    public String getTaskNodeKey() {
        return taskNodeKey;
    }

    public void setTaskNodeKey(String taskNodeKey) {
        this.taskNodeKey = taskNodeKey;
    }

    public String getNextNodeKey() {
        return nextNodeKey;
    }

    public void setNextNodeKey(String nextNodeKey) {
        this.nextNodeKey = nextNodeKey;
    }

    public String getImplementationName() {
        return implementationName;
    }

    public void setImplementationName(String implementationName) {
        this.implementationName = implementationName;
    }

    public String getTaskProcessXmlContent() {
        return taskProcessXmlContent;
    }

    public void setTaskProcessXmlContent(String taskProcessXmlContent) {

        this.taskProcessXmlContent = taskProcessXmlContent;
    }

    public Map<String, Object> getFormDataMap() {
        return formDataMap;
    }

    public void setFormDataMap(String formDataMap) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            this.formDataMap = objectMapper.readValue(formDataMap, Map.class);
        } catch (Exception e) {
            // 处理异常，例如日志记录或抛出自定义异常
            e.printStackTrace();
        }
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("BpmRunNodeVo{");
        sb.append("taskProcessKey='").append(taskProcessKey).append('\'');
        sb.append(", taskNodeKey='").append(taskNodeKey).append('\'');
        sb.append(", nextNodeKey='").append(nextNodeKey).append('\'');
        sb.append(", implementationName='").append(implementationName).append('\'');
        sb.append(", taskProcessXmlContent='").append(taskProcessXmlContent).append('\'');
        sb.append(", formDataMap=").append(formDataMap);
        sb.append(", tableName='").append(tableName).append('\'');
        sb.append('}');
        return sb.toString();
    }

    public BpmRunNodeVo() {
    }

    public BpmRunNodeVo(String taskProcessKey, String taskNodeKey, String nextNodeKey, String implementationName, String taskProcessXmlContent, Map<String, Object> formDataMap, String tableName) {
        this.taskProcessKey = taskProcessKey;
        this.taskNodeKey = taskNodeKey;
        this.nextNodeKey = nextNodeKey;
        this.implementationName = implementationName;
        this.taskProcessXmlContent = taskProcessXmlContent;
        this.formDataMap = formDataMap;
        this.tableName = tableName;
    }
}
