package com.mortals.xhx.flowable.task;

import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.code.flowable.runtime.CommentTypeEnum;
import com.mortals.xhx.common.code.flowable.runtime.ProcessStatusEnum;
import com.mortals.xhx.flowable.AttachmentEntity;
import com.mortals.xhx.flowable.BaseTaskReq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 任务执行(审批参数)
 *
 * @author: zxfei
 * @date: 2021/8/26 17:23
 */
@Data
@ApiModel(value = "CompleteTask" , description = "审批参数")
public class CompleteTaskReq extends BaseTaskReq implements Serializable {

    private static final long serialVersionUID = -5583096980348786337L;
    /**
     * 流程标题 选填   只有在重新发起的时候才会修改表单标题
     */
    @ApiModelProperty(value = "流程标题")
    private String formTitle;
    /**
     * 任务参数 选填
     */
    @ApiModelProperty(value = "任务参数")
    private Map<String, Object> variables;

    /**
     * 任务参数 附件 选填
     */
    @ApiModelProperty(value = "任务参数")
    private List<AttachmentEntity> attachments;


    public static void main(String[] args) {

        CompleteTaskReq completeTaskReq = new CompleteTaskReq();
        completeTaskReq.setFormTitle("标题");
        completeTaskReq.setProcessInstanceId("123");
        completeTaskReq.setActivityId("activID");
        completeTaskReq.setTaskId("12312");
        completeTaskReq.setCommentTypeEnum(CommentTypeEnum.BH);
        completeTaskReq.setProcessStatusEnum(ProcessStatusEnum.BJ);
        completeTaskReq.setActivityName("2322133");

        HashMap<String, Object> variables = new HashMap<>();
        variables.put("form","12312");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("json","213123");
        variables.put("test",hashMap);
        completeTaskReq.setVariables(variables);

        AttachmentEntity attachmentEntity = new AttachmentEntity();
        attachmentEntity.setDesc("1231232");
        attachmentEntity.setName("ffff");
        attachmentEntity.setType("123132");
        attachmentEntity.setUrl("http://11111.png");


        ArrayList<AttachmentEntity> list = new ArrayList<>();
        list.add(attachmentEntity);

        completeTaskReq.setAttachments(list);


        System.out.println(JSON.toJSONString(completeTaskReq));


    }

}
