package com.chushang.inspection.terminal.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chushang.common.mybatis.base.BaseEntity;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import com.chushang.inspection.work.dto.WrkIcbcJsReceive;
import com.chushang.inspection.work.enums.TerminalTypeOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
  * @auther: zhao
  * @date: 2024/6/21 16:39
  */
/**
 * 终端信息表
 */
@Data
@EqualsAndHashCode(callSuper=true)
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "st_terminal")
public class Terminal extends BaseEntity {
    /**
     * 主键
     */
    @TableId(value = "terminal_id", type = IdType.ASSIGN_ID)
    private Long terminalId;

    /**
     * 租户id
     */
    @TableField(value = "dept_id")
    private Long deptId;

    /**
     * 任务id
     */
    @TableField(value = "task_id")
    private Long taskId;

    /**
     * 下级任务id
     */
    @TableField(value = "lower_task_id")
    private Long lowerTaskId;

    /**
     * 所属商户id
     */
    @TableField(value = "store_id")
    private Long storeId;

    /**
     * 所属商户编号
     */
    @TableField(value = "store_no")
    private String storeNo;

    /**
     * 终端sn号
     */
    @TableField(value = "terminal_sn")
    private String terminalSn;

    /**
     * 终端编号
     */
    @TableField(value = "terminal_no")
    private String terminalNo;

    /**
     * 终端类型
     */
    @TableField(value = "terminal_type")
    private Integer terminalType;

    /**
     * 终端型号
     */
    @TableField(value = "terminal_model")
    private String terminalModel;

    /**
     * 版本号
     */
    @TableField(value = "terminal_version")
    private String terminalVersion;

    /**
     * 终端地址
     */
    @TableField(value = "terminal_address")
    private String terminalAddress;

    /**
     * 终端来源
     */
    @TableField(value = "terminal_source")
    private Integer terminalSource;

    /**
     * 终端产权人
     */
    @TableField(value = "terminal_property")
    private Integer terminalProperty;

    /**
     * 是否占用
     */
    @TableField(value = "occupy")
    private Integer occupy;

    /**
     * 终端状态
     */
    @TableField(value = "terminal_status")
    private Integer terminalStatus;
    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;


    public Terminal save(Store store, WrkIcbcJsReceive dto) {
        this.storeId = store.getStoreId();
        this.storeNo = store.getStoreNo();
        this.taskId = store.getTaskId();
        this.lowerTaskId = store.getLowerTaskId();
        this.deptId = store.getDeptId();
        this.createBy = store.getCreateBy();
        this.terminalNo = dto.getTermId();
        this.terminalSn = dto.getDeviceNo();
        this.terminalType = TerminalTypeOperation.valueOfCode(dto.getDeviceType());
        this.remark = dto.getNoteMsg();
        this.occupy = 0;
        return this;
    }
}
