/*
 * Copyright 2015-2020 All rights reserved.
 */
package com.scm.api.contract.entity.common;

import com.set.direwolf.core.mybatis.BaseEntity;
import com.set.direwolf.core.utils.IDUtil;

import javax.validation.constraints.Size;
import java.util.Calendar;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Objects;

/**
 * <pre>
 * ----auto generated-------
 * 日志信息Entity
 * </pre>
 *
 * @author wangning
 * @version 2020-04-29 09:58:09
 */
public class TOperatingLog extends BaseEntity<TOperatingLog, String> {

    private static final long serialVersionUID = 1L;
    /**
     * 操作日期
     */
    private Date operTime;
    /**
     * 操作日期区间
     */
    private Date[] operTimeRange;
    /**
     * 操作人员账号
     */
    private String operPerAccount;
    /**
     * 操作模块
     */
    private String operModule;
    /**
     * 操作动作
     */
    private String operAction;
    /**
     * 运维人员
     */
    private String operMaintenPer;
    /**
     * URL
     */
    private String operUrl;
    /**
     * 合同编号
     */
    private String operContractCode;
    /**
     * 采购申请号
     */
    private String operPurchaseApplyCode;
    /**
     * 订单编号
     */
    private String operOrderCode;
    /**
     * 提交次数
     */
    private Integer operSubmitCount;
    /**
     * 备注
     */
    private String operRemark;

    public TOperatingLog() {
    }
    
    public TOperatingLog(String operPerAccount, String operModule, String operAction, 
			String operUrl, String operContractCode, String operOrderCode, String operPurchaseApplyCode, String operRemark) {
		this.isNewRecord = true;
		this.id = IDUtil.createUUID();
		this.operTime = new Date();
		this.operPerAccount= operPerAccount;
		this.operModule = operModule;
		this.operAction = operAction;
		this.operUrl = operUrl;	
		this.operContractCode = operContractCode;	
		this.operOrderCode = operOrderCode;	
		this.operPurchaseApplyCode = operPurchaseApplyCode;
		this.operRemark = operRemark;	
		this.operSubmitCount = 0;	
	}

    public TOperatingLog(String id) {
        this.id = id;
    }

    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getOperTime() {
        return getCopyOfDate(operTime);
    }

    public void setOperTime(Date operTime) {
        this.operTime = getCopyOfDate(operTime);
    }
    
    public Date[] getOperTimeRange() {
        return operTimeRange;
    }

    public Date[] setOperTimeRange(Date[] operTimeRange) {
        return this.operTimeRange = operTimeRange;
    }

    public Date getBeginOperTime() {
        if (this.operTimeRange != null && operTimeRange.length > 0) {
            return this.operTimeRange[0];
        }
        return null;
    }

    public Date getEndOperTime() {
        Date end = null;
        if (this.operTimeRange != null && operTimeRange.length > 1) {
            end = this.operTimeRange[1];
        }
        if (end != null) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(end);
            // 如果结束日期的时间为00:00:00，则修改为23:59:59
            if (cal.get(Calendar.HOUR) == 0 && cal.get(Calendar.MINUTE) == 0
                    && cal.get(Calendar.SECOND) == 0) {
                cal.add(Calendar.DATE, 1);
                cal.add(Calendar.SECOND, -1);
                end = cal.getTime();
            }
        }
        return end;
    }
    
    @Size(max = 60, message = "操作人员账号长度限制从0到60字节")
    public String getOperPerAccount() {
        return operPerAccount;
    }

    public void setOperPerAccount(String operPerAccount) {
        this.operPerAccount = operPerAccount;
    }
    
    @Size(max = 100, message = "操作模块长度限制从0到100字节")
    public String getOperModule() {
        return operModule;
    }

    public void setOperModule(String operModule) {
        this.operModule = operModule;
    }
    
    @Size(max = 100, message = "操作动作长度限制从0到100字节")
    public String getOperAction() {
        return operAction;
    }

    public void setOperAction(String operAction) {
        this.operAction = operAction;
    }
    
    @Size(max = 50, message = "运维人员长度限制从0到50字节")
    public String getOperMaintenPer() {
        return operMaintenPer;
    }

    public void setOperMaintenPer(String operMaintenPer) {
        this.operMaintenPer = operMaintenPer;
    }
    
    @Size(max = 500, message = "URL长度限制从0到500字节")
    public String getOperUrl() {
        return operUrl;
    }

    public void setOperUrl(String operUrl) {
        this.operUrl = operUrl;
    }
    
    @Size(max = 1000, message = "合同编号长度限制从0到1000字节")
    public String getOperContractCode() {
        return operContractCode;
    }

    public void setOperContractCode(String operContractCode) {
        this.operContractCode = operContractCode;
    }
    
    @Size(max = 3000, message = "采购申请号长度限制从0到3000字节")
    public String getOperPurchaseApplyCode() {
        return operPurchaseApplyCode;
    }

    public void setOperPurchaseApplyCode(String operPurchaseApplyCode) {
        this.operPurchaseApplyCode = operPurchaseApplyCode;
    }
    
    @Size(max = 1000, message = "订单编号长度限制从0到1000字节")
    public String getOperOrderCode() {
        return operOrderCode;
    }

    public void setOperOrderCode(String operOrderCode) {
        this.operOrderCode = operOrderCode;
    }
    
    public Integer getOperSubmitCount() {
        return operSubmitCount;
    }

    public void setOperSubmitCount(Integer operSubmitCount) {
        this.operSubmitCount = operSubmitCount;
    }
    
    public String getOperRemark() {
        return operRemark;
    }

    public void setOperRemark(String operRemark) {
        this.operRemark = operRemark;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        TOperatingLog that = (TOperatingLog) o;
        return Objects.equals(operTime, that.operTime) && Objects.equals(operPerAccount, that.operPerAccount) && Objects.equals(operModule, that.operModule) && Objects.equals(operAction, that.operAction) && Objects.equals(operMaintenPer, that.operMaintenPer) && Objects.equals(operUrl, that.operUrl) && Objects.equals(operContractCode, that.operContractCode) && Objects.equals(operPurchaseApplyCode, that.operPurchaseApplyCode) && Objects.equals(operOrderCode, that.operOrderCode) && Objects.equals(operSubmitCount, that.operSubmitCount) && Objects.equals(operRemark, that.operRemark);
    }

    @Override
    public int hashCode() {
        return Objects.hash(operTime, operPerAccount, operModule, operAction, operMaintenPer, operUrl, operContractCode, operPurchaseApplyCode, operOrderCode, operSubmitCount, operRemark);
    }

    @Override
    public String toString() {
        return "TOperatingLog{" + "operTime='" + operTime + '\'' + "operPerAccount='" + operPerAccount + '\'' + "operModule='" + operModule + '\'' + "operAction='" + operAction + '\'' + "operMaintenPer='" + operMaintenPer + '\'' + "operUrl='" + operUrl + '\'' + "operContractCode='" + operContractCode + '\'' + "operPurchaseApplyCode='" + operPurchaseApplyCode + '\'' + "operOrderCode='" + operOrderCode + '\'' + "operSubmitCount='" + operSubmitCount + '\'' + "operRemark='" + operRemark + '\'' +
                "} " + super.toString();
    }
}