package cn.sagacloud.server.scheduler.models

import com.alibaba.fastjson.annotation.JSONField
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import com.sybotan.service.models.SBaseEntity
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
import java.util.*
import javax.persistence.Column
import javax.persistence.Id
import javax.persistence.Table
import kotlin.collections.ArrayList

/**
 * 任务实体
 *
 * @author jxing
 */
@ApiModel(description = "任务实体类")
@Table(name = "scheduler_str.task")
open class TaskEntity: SBaseEntity() {

    /** 表自增id*/
    @ApiModelProperty(value = "自增id")
    @Column(name = "id", insertable = true, updatable = false)
    @Id
    @JsonProperty(value = "Id")
    var id: String? = null

    /** task name */
    @ApiModelProperty(value = "任务名")
    @Column(name = "task_name")
    @JsonProperty(value = "Name")
    var name: String? = null

    /** cmd to be executed. */
    @ApiModelProperty(value = "任务中要被执行的命令")
    @Column(name = "task_cmd")
    @JsonProperty(value = "Cmd")
    var cmd: String? = null

    /** task parameter */
    @ApiModelProperty(value = "任务参数")
    @Column(name = "task_param")
    @JsonProperty(value = "Param")
    var param: String? =null

    /** task_status 0 Waiting, 1 Sending, 2 Sent, 3 FileDownloadException, 4 CommandExecuteException, 5 Finished*/
    @ApiModelProperty(value = "任务状态 0 Waiting, 1 Sending, 2 Sent, 3 FileDownloadException, 4 CommandExecuteException, 5 Finished", example = "1000")
    @Column(name = "task_status", insertable = false)
    @JsonProperty(value = "Status")
//    @JsonIgnore
    var status: Int? = null

    /** task 执行结果 */
    @ApiModelProperty(value = "任务执行结果")
    @Column(name = "task_result_json", insertable = false)
    @JsonProperty(value = "ResultJson")
    var resultJson: String? =null


    /** task 分发下去的时间 */
    @ApiModelProperty(value = "任务分发时间点")
    @Column(name = "task_sent_time", insertable = false)
    @JsonProperty(value = "SentTime")
    var sentTime: Long? =null


    /** 上一个获得该任务的客户端 */
    @ApiModelProperty(value = "上一个获得该任务的客户端")
    @Column(name = "task_last_client", insertable = false)
    @JsonProperty(value = "LastClient")
    var lastClient: String? =null


    /** 任务预期执行时间(单位是s) */
    @ApiModelProperty(value = "任务预期执行时间(单位是s)")
    @Column(name = "task_expected_finish_time")
    @JsonProperty(value = "ExpectedFinishTime")
    var expectedFinishTime: Long? =null

//    /** 任务添加时间 */
//    @ApiModelProperty(value = "任务添加时间", example = "2019-06-18 17:58:00")
//    @Column(name = "task_add_time", insertable = false, updatable = false)
//    @JsonProperty(value = "addTime")
//    var addTime: Date? =null

    /** 任务中的下载子任务 */
    @JsonProperty(value = "DownloadTaskList")
    var downloadTaskList: ArrayList<DownloadEntity> = ArrayList<DownloadEntity>()

    /** projectId */
    @ApiModelProperty(value = "任务中要被执行的命令")
    @Column(name = "project_id")
    @JsonProperty(value = "ProjectId")
    var projectId: String? = null

    /** modelId */
    @ApiModelProperty(value = "任务参数")
    @Column(name = "model_id")
    @JsonProperty(value = "ModelId")
    var modelId: String? =null

    /** task name */
    @ApiModelProperty(value = "任务名")
    @Column(name = "task_downloaded_time")
    @JsonProperty(value = "DownloadFinishTime")
    @JSONField(name = "DownloadFinishTime")
    var downloadFinishTime: Date? = null

    @JsonProperty(value = "FloorServerUrl")
    @JSONField(name = "FloorServerUrl")
    @Column(name = "floor_server_url")
    var floorServerUrl:String? = null

    @JsonProperty(value = "UseablePhaseName")
    @JSONField(name = "UseablePhaseName")
    @Column(name = "useable_phase_name")
    var useablePhaseName:String? = null

    @JsonProperty(value = "SagaSign")
    @JSONField(name = "SagaSign")
    @Column(name = "saga_sign")
    var sagaSign:String? = null

    @JsonProperty(value = "CheckItems")
    @JSONField(name = "CheckItems")
    @Column(name = "check_items")
    var checkItems:String? = null

    @JsonProperty(value = "FacilityParameters")
    @JSONField(name = "FacilityParameters")
    @Column(name = "facility_parameters")
    var facilityParameters:String? = null

    @JsonProperty(value = "SpaceParameters")
    @JSONField(name = "SpaceParameters")
    @Column(name = "space_parameters")
    var spaceParameters:String? = null

    @JsonProperty(value = "RoomParameters")
    @JSONField(name = "RoomParameters")
    @Column(name = "room_parameters")
    var roomParameters:String? = null

    @JsonProperty(value = "MEPCurveParameters")
    @JSONField(name = "MEPCurveParameters")
    @Column(name = "mepcurve_parameters")
    var mEPCurveParameters:String? = null

    @JsonProperty(value = "EquipComponentCode")
    @JSONField(name = "EquipComponentCode")
    @Column(name = "equip_code")
    var equipComponentCode:String? = null
} // Class AppendixType














