package com.example.iot_controlhost.model.net;

import com.google.gson.annotations.SerializedName;

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

/**
 * @Description 开始共育蚕批次及蚕种
 * @Author DuanKaiji
 * @CreateTime 2023年11月06日 14:47:28
 */
public class Batch {

    @SerializedName("Code")
    private int code;
    @SerializedName("Message")
    private String message;
    @SerializedName("Data")
    private List<DataDTO> data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<DataDTO> getData() {
        return data;
    }

    public void setData(List<DataDTO> data) {
        this.data = data;
    }

    public static class DataDTO {
        @SerializedName("BatchSysid")
        private String batchSysid;
        @SerializedName("BatchName")
        private String batchName;
        @SerializedName("Items")
        private List<ItemsDTO> items;

        public String getBatchSysid() {
            return batchSysid;
        }

        public void setBatchSysid(String batchSysid) {
            this.batchSysid = batchSysid;
        }

        public String getBatchName() {
            return batchName;
        }

        public void setBatchName(String batchName) {
            this.batchName = batchName;
        }

        public List<ItemsDTO> getItems() {
            return items;
        }

        public void setItems(List<ItemsDTO> items) {
            this.items = items;
        }

        public static class ItemsDTO {
            @SerializedName("SilkwormEggName")
            private String silkwormEggName;
            @SerializedName("IntelligentControlProgramID")
            private String intelligentControlProgramID;
            @SerializedName("StartTime")
            private String startTime;
            @SerializedName("EndTime")
            private String endTime;
            @SerializedName("SilkwormEggId")
            private String SilkwormEggId;

            public String getSilkwormEggName() {
                return silkwormEggName;
            }

            public void setSilkwormEggName(String silkwormEggName) {
                this.silkwormEggName = silkwormEggName;
            }

            public String getIntelligentControlProgramID() {
                return intelligentControlProgramID;
            }

            public void setIntelligentControlProgramID(String intelligentControlProgramID) {
                this.intelligentControlProgramID = intelligentControlProgramID;
            }

            public Date getStartTime() {
                return parseDate(startTime);
            }

            public void setStartTime(String startTime) {
                this.startTime = startTime;
            }

            public Date getEndTime() {
                return parseDate(endTime);
            }

            public void setEndTime(String endTime) {
                this.endTime = endTime;
            }

            public String getSilkwormEggId() {
                return SilkwormEggId;
            }

            public void setSilkwormEggId(String silkwormEggId) {
                SilkwormEggId = silkwormEggId;
            }

            private Date parseDate(String dateString) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                try {
                    return dateFormat.parse(dateString);
                } catch (ParseException e) {
                    // 处理解析异常
                    e.printStackTrace();
                    return null; // 或者抛出自定义异常
                }
            }
        }
    }
}
