package com.nantian.cloud.dbcapp.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mysql.cj.util.StringUtils;
import lombok.Data;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class ConfigureGaugeVo{
    private Long id;
    private String enterpriseCode; //社会行用统一编码
    private String nextAlignDate;
    private String alignOrg; //检测机构
    private String unAlignReason; //未检定/校准原因
    private String location; //安装地点
    private String installer; //安装方
    private String installTime;
    private String linkSys; //接入系统
    private String currentState; //当前状态
    private String stateChangeTime;
    private String serNo; //设备出产序列号
    private String barCode; //计量器具二维码
    private String meterName; //计量器名称
    private String meterType;
    private String meterLevel; //器具等级
    private String params; //计量相关参数
    private String dataCode; //所属上报数据组合编码
    private String reportArithmetic; //与上报数据组合编码算术关系
    private String reportRatio; //与上报数据组合编码算术系数
    private String manufacturer; //生产厂家
    private String model; //规格型号
    private String precisionLevel; //精确度等级
    private String ranges; //测量范围
    private String manageNo; //管理编号
    private String alignState; //检定校准状态
    private String alignCycle; //检定校准周期
    private String LastAlignDate;
    private String state; //状态
    private String remark; //备注
    private String paramsType; //参数类型
    private String uploadedCountry; //是否已上传过
    private String digest; //摘要
    private String quoted; //引用
    private String del_flag;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
    private Date nextAlignDateTmp;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
    private Date installTimeTmp;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
    private Date stateChangeTimeTmp;

    //计量器具与采集配置项关联状态
    @TableField(exist = false)
    private String relevanceState;

    @TableField(exist = false)
    private String auditStatus;

    public void setDateTmp() throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        if(!StringUtils.isNullOrEmpty(this.installTime)){
            String tmp = this.installTime;
            tmp = tmp.endsWith("-") ? tmp+"01" : tmp;
            this.installTimeTmp = sdf.parse(tmp);
        }
        if(!StringUtils.isNullOrEmpty(this.nextAlignDate)){
            String tmp = this.nextAlignDate;
            tmp = tmp.endsWith("-") ? tmp+"01" : tmp;
            this.nextAlignDateTmp = sdf.parse(tmp);
        }
        if(!StringUtils.isNullOrEmpty(this.stateChangeTime)){
            String tmp = this.stateChangeTime;
            tmp = tmp.endsWith("-") ? tmp+"01" : tmp;
            this.stateChangeTimeTmp = sdf.parse(tmp);
        }
    }
}
