package org.jeecg.modules.itdmGongDan.vo;


import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 计划员查询返回的列表对象(完整版，包括各种名称)
 * */
@Data
@Accessors(chain = true)
public class ItdmJHYQueryListVO {

    /**委托id*/
    @Excel(name = "委托id", width = 15)
    @ApiModelProperty(value = "委托id")
    private String weituoId;
    /**样品id*/
    @Excel(name = "样品id", width = 15)
    @ApiModelProperty(value = "样品id")
    private String yangpinId;
    /**检测项目id*/
    @Excel(name = "检测项目id", width = 15)
    @ApiModelProperty(value = "检测项目id")
    private java.lang.String testItemsId;
    /**检测项目*/
    @Excel(name = "检测项目", width = 15)
    @ApiModelProperty(value = "检测项目")
    private String testItems;
    /**试验计划id*/
    @Excel(name = "试验计划id", width = 15)
    @ApiModelProperty(value = "试验计划id")
    private String testPlanId;
    /**设备id*/
    @Excel(name = "设备id", width = 15)
    @ApiModelProperty(value = "设备id")
    private java.lang.String shebeiId;
    /**项目经理*/
    @Excel(name = "项目经理", width = 15)
    @ApiModelProperty(value = "项目经理")
    private java.lang.String pm;
    /**计划开始日期*/
    @Excel(name = "计划开始日期", width = 15, format = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "计划开始日期")
    private java.util.Date jihuaStartDate;
    /**计划结束日期*/
    @Excel(name = "计划结束日期", width = 15, format = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "计划结束日期")
    private java.util.Date jihuaEndDate;
    /**状态*/
    @Excel(name = "状态", width = 15, dicCode = "test_plan_status")
    @Dict(dicCode = "test_plan_status")
    @ApiModelProperty(value = "状态")
    private java.lang.Integer status;
    /**报告编号*/
    @Excel(name = "报告编号", width = 15)
    @ApiModelProperty(value = "报告编号")
    private java.lang.String reportNo;
    /**传感器id*/
    @Excel(name = "传感器id", width = 20)
    @ApiModelProperty(value = "传感器id")
    private java.lang.String chuanganqi;
    /**委托编号*/
    @Excel(name = "委托编号", width = 15)
    @ApiModelProperty(value = "委托编号")
    private String weituoNo;
    /**样品名称*/
    @Excel(name = "样品名称", width = 15)
    @ApiModelProperty(value = "样品名称")
    private java.lang.String sampleName;
    /**设备名称*/
    @Excel(name = "设备名称", width = 15)
    @ApiModelProperty(value = "设备名称")
    private java.lang.String deviceName;
    /**父id*/
    @Excel(name = "父id", width = 20)
    @ApiModelProperty(value = "父id")
    private java.lang.String parent;
    /**持续时间*/
    @Excel(name = "持续时间", width = 20)
    @ApiModelProperty(value = "持续时间")
    private java.lang.Integer lastTime;
    /**status转化*/
    @Excel(name = "status转化", width = 15)
    @ApiModelProperty(value = "status转化")
    private java.lang.String statusC;
    /**传感器数组*/
    @Excel(name = "传感器数组", width = 15)
    @ApiModelProperty(value = "传感器数组")
    private java.lang.String[] chuanganqiArray;
    /**前端用的到，用来放试验计划id*/
    @Excel(name = "试验计划id", width = 15)
    @ApiModelProperty(value = "试验计划id")
    private String id;

    /**实绩开始日期*/
    @Excel(name = "实绩开始日期", width = 15, format = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "实绩开始日期")
    private java.util.Date shijiStartDate;
    /**实绩结束日期*/
    @Excel(name = "实绩结束日期", width = 15, format = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "实绩结束日期")
    private java.util.Date shijiEndDate;

    /**是否为实绩，1为实绩，0非实绩*/
    @ApiModelProperty(value = "是否为实绩，1为实绩，0非实绩")
    private java.lang.String izShiji;


    /**测试*/
    public static ItdmJHYQueryListVO toItdmJHYQueryListVO(ItdmJCXMAndSYJHVO itdmVO, String weituoNo, String sampleName, String deviceName){
        ItdmJHYQueryListVO vo = new ItdmJHYQueryListVO();
        vo.setWeituoId(itdmVO.getWeituoId());
        vo.setYangpinId(itdmVO.getYangpinId());
        vo.setShebeiId(itdmVO.getShebeiId());
        vo.setTestItems(itdmVO.getTestItems());
        vo.setDeviceName(deviceName);
        vo.setSampleName(sampleName);
        vo.setWeituoNo(weituoNo);
        vo.setChuanganqi(itdmVO.getChuanganqi());
        vo.setStatus(itdmVO.getStatus());
        vo.setPm(itdmVO.getPm());
        vo.setChuanganqi(itdmVO.getChuanganqi());
        vo.setTestPlanId(itdmVO.getTestPlanId());
        vo.setReportNo(itdmVO.getReportNo());
        vo.setJihuaStartDate(itdmVO.getJihuaStartDate());
        vo.setJihuaEndDate(itdmVO.getJihuaEndDate());
        vo.setTestItemsId(itdmVO.getTestItemsId());
        if(itdmVO.getJihuaEndDate()!=null && itdmVO.getTestItemsId()!=null){
            int days = (int) ((itdmVO.getJihuaEndDate().getTime() - itdmVO.getJihuaStartDate().getTime()) / (1000*3600*24));
            vo.setLastTime(days);
        }
        return vo;
    }

    /**填入委托编号，计算持续时间，状态转化——计划员查询列表对象*/
    public static ItdmJHYQueryListVO toItdmJHYQueryListVO3(ItdmJHYQueryListVO vo, String weituoNo, ShijiDate shijiDate){
        vo.setId(vo.getTestItemsId());//用来放检测项目id
        vo.setWeituoNo(weituoNo);
        if(vo.getJihuaEndDate()!=null && vo.getTestItemsId()!=null){
            int days = (int) ((vo.getJihuaEndDate().getTime() - vo.getJihuaStartDate().getTime()) / (1000*3600*24));
            vo.setLastTime(days+1);
        }else {
            int days = 1;
            vo.setLastTime(days);//如果没有开始时间和结束时间，初始化开始时间为今天，持续时间为1为
            vo.setJihuaStartDate(new Date());
        }
        if(vo.getStatus()!=null){
            if(vo.getStatus()==0) vo.setStatusC("未确认");
            else if(vo.getStatus()==1) vo.setStatusC("已确认");
            else if(vo.getStatus()==2) vo.setStatusC("完成");
        }

        if(vo.getChuanganqi()!=null && !vo.getChuanganqi().equals("")){
            String[] arr = vo.getChuanganqi().split(",");
            vo.setChuanganqiArray(arr);
        }
        if(shijiDate!=null){
            vo.setShijiStartDate(shijiDate.getShijiStartDate());
            vo.setShijiEndDate(shijiDate.getShijiEndDate());
        }
        return vo;
    }
}
