package com.boman.domain.dto;


import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import java.util.*;

/**
 * @author shiqian
 * @date 2021年05月26日 15:29
 **/
public class ProcessDto {

    /**
     *
     */
    private  String dbname;

    private JSONObject businessObj;
    /**
     * 流程实例id
     */
    @JSONField
    private Long instanceId;

    /**
     * 流程实例id-多个
     */
    @JSONField
    private String instanceIds;

    /**
     * 流程实例版本
     */
    private Integer rev;

    @JSONField
    private Long initiator;

    /**
     * 发起人：称谓
     */
    @JSONField
    private String initiatorName;

    /**
     * 业务数据编号
     */
    @JSONField
    private Long businessCode;

    /**
     * 业务数据
     */
    @JSONField(serialize = false, deserialize = false)
    private JSONObject businessBody;

    /**
     * 业务回调路径
     */
    @JSONField
    private String businessUrl;

    /**
     * 业务回调路径
     */
    @JSONField
    private String formUrl;

    /**
     * 业务单据修改明细
     */
    @JSONField
    private JSONObject changeDetail;

    /**
     * 流程状态
     */
    @JSONField
    private Short status;

    /**
     * 检索开始时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm")
    private Date startTime;

    /**
     * 检索结束时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm")
    private Date endTime;

    @JSONField
    private Long moduleId;

    @JSONField(serialize = false, deserialize = false)
    private Long nodeId;

    @JSONField
    private Long businessType;

    @JSONField
    private Long changeUser;

    @JSONField
    private String userName;

    /**
     * 业务测单据id的集合
     */
    @JSONField(name = "businessCodes")
    private String businessCodes;

    /**
     * 业务测英文表名
     */
    @JSONField
    private String businessTypeName;

    /**
     * 业务系统需要校验的单对象id
     */
    @JSONField
    private List<Long> businessCheckData;

    /**
     * 异常编号
     */
    private String errorCode;

    /**
     * 索引信息
     */
    private String businessNumber;

    /**
     * 定制页面可能需要提交的业务数据体
     */
    @JSONField
    private JSONObject customizeBody;

    @JSONField(serialize = false, deserialize = false)
    private Set<Short> statusSets;

    @JSONField(serialize = false, deserialize = false)
    private List<Long> businessCodeList;

    @JSONField(serialize = false, deserialize = false)
    private Boolean async;

    /**
     * 强制终止
     */
    private Boolean hardShut;

    /**
     * 转储业务编号
     *
     * @return
     */
    public ProcessDto collectBusinessCodes() {
        Set<Long> businessCodeSet = new HashSet<>(1);
        if (businessCode != null) {
            businessCodeSet.add(businessCode);
        }
        if (businessCodes != null && businessCodes.trim().length() != 0) {
            String[] codeArray = businessCodes.trim().split(",");
            Arrays.stream(codeArray).forEach(code -> businessCodeSet.add(Long.parseLong(code)));
        }
        businessCodeList = new ArrayList<>(businessCodeSet);
        return this;
    }

    public String getDbname() {
        return dbname;
    }

    public void setDbname(String dbname) {
        this.dbname = dbname;
    }

    public JSONObject getBusinessObj() {
        return businessObj;
    }

    public void setBusinessObj(JSONObject businessObj) {
        this.businessObj = businessObj;
    }

    public Long getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(Long instanceId) {
        this.instanceId = instanceId;
    }

    public String getInstanceIds() {
        return instanceIds;
    }

    public void setInstanceIds(String instanceIds) {
        this.instanceIds = instanceIds;
    }

    public Integer getRev() {
        return rev;
    }

    public void setRev(Integer rev) {
        this.rev = rev;
    }

    public Long getInitiator() {
        return initiator;
    }

    public void setInitiator(Long initiator) {
        this.initiator = initiator;
    }

    public String getInitiatorName() {
        return initiatorName;
    }

    public void setInitiatorName(String initiatorName) {
        this.initiatorName = initiatorName;
    }

    public Long getBusinessCode() {
        return businessCode;
    }

    public void setBusinessCode(Long businessCode) {
        this.businessCode = businessCode;
    }

    public JSONObject getBusinessBody() {
        return businessBody;
    }

    public void setBusinessBody(JSONObject businessBody) {
        this.businessBody = businessBody;
    }

    public String getBusinessUrl() {
        return businessUrl;
    }

    public void setBusinessUrl(String businessUrl) {
        this.businessUrl = businessUrl;
    }

    public String getFormUrl() {
        return formUrl;
    }

    public void setFormUrl(String formUrl) {
        this.formUrl = formUrl;
    }

    public JSONObject getChangeDetail() {
        return changeDetail;
    }

    public void setChangeDetail(JSONObject changeDetail) {
        this.changeDetail = changeDetail;
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Long getModuleId() {
        return moduleId;
    }

    public void setModuleId(Long moduleId) {
        this.moduleId = moduleId;
    }

    public Long getNodeId() {
        return nodeId;
    }

    public void setNodeId(Long nodeId) {
        this.nodeId = nodeId;
    }

    public Long getBusinessType() {
        return businessType;
    }

    public void setBusinessType(Long businessType) {
        this.businessType = businessType;
    }

    public Long getChangeUser() {
        return changeUser;
    }

    public void setChangeUser(Long changeUser) {
        this.changeUser = changeUser;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getBusinessCodes() {
        return businessCodes;
    }

    public void setBusinessCodes(String businessCodes) {
        this.businessCodes = businessCodes;
    }

    public String getBusinessTypeName() {
        return businessTypeName;
    }

    public void setBusinessTypeName(String businessTypeName) {
        this.businessTypeName = businessTypeName;
    }

    public List<Long> getBusinessCheckData() {
        return businessCheckData;
    }

    public void setBusinessCheckData(List<Long> businessCheckData) {
        this.businessCheckData = businessCheckData;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getBusinessNumber() {
        return businessNumber;
    }

    public void setBusinessNumber(String businessNumber) {
        this.businessNumber = businessNumber;
    }

    public JSONObject getCustomizeBody() {
        return customizeBody;
    }

    public void setCustomizeBody(JSONObject customizeBody) {
        this.customizeBody = customizeBody;
    }

    public Set<Short> getStatusSets() {
        return statusSets;
    }

    public void setStatusSets(Set<Short> statusSets) {
        this.statusSets = statusSets;
    }

    public List<Long> getBusinessCodeList() {
        return businessCodeList;
    }

    public void setBusinessCodeList(List<Long> businessCodeList) {
        this.businessCodeList = businessCodeList;
    }

    public Boolean getAsync() {
        return async;
    }

    public void setAsync(Boolean async) {
        this.async = async;
    }

    public Boolean getHardShut() {
        return hardShut;
    }

    public void setHardShut(Boolean hardShut) {
        this.hardShut = hardShut;
    }
}
