CamlineWcaSelected5Dto.java

package com.mycim.valueobject.edcspc.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Luopeng.Wang
 * @version 6.0.0
 * @date 2019/9/18
 **/
public class CamlineWcaSelected5Dto extends CamlineObjectDto {
    public static final String HOLD_LOT = "HoldLot";

    public static final String HOLD_LOT_LIST = "HoldLotList";

    public static final String HOLD_EQUIPMENT = "HoldEquipment";

    public static final String HOLD_SUBEQUIPMENT = "HoldSubEquipment";

    public static final String HOLD_RECIPE = "HoldRecipe";

    private int lds_id;

    private String station_user;

    private String author;

    private int viol_comment_date;

    private short viol_count;

    private short ca_attr_nr;

    private short exkey_recnum;

    private short datkey_recnum;

    private int tot_viol_count;

    private int tot_attribute_count;

    private int tot_cf_count;

    private int tag_num;

    private int ca_tag_num;

    private String[] viol_comment;

    private String[] parameter_name;

    private long[] sample_id;

    private int[] sample_date;

    private int[] prio_viol_id;

    private int[] ch_id;

    private int[] ckc_id;

    private String[] ch_state;

    private String[] set_spc_flag;

    private String[] spc_flag_extern;

    private String[] spc_com_extern;

    private int[] ca_id_selected;

    private String[] ca_name;

    private short[] ca_attr_num;

    private short[] sample_viol_count;

    private int[] prev_ca_id;

    private int[] smp_defect_count;

    private short[] smp_cf_count;

    private int[] smp_tag_count;

    private int[] ca_tag_count;

    private String[] ca_attribute;

    private short[] exkey_id;

    private String[] exkey_name;

    private String[] exkey_value;

    private short[] datkey_id;

    private String[] datkey_name;

    private String[] datkey_value;

    private int[] all_viol_id;

    private String[] defect_type;

    private String[] defect_location;

    private String[] defect_cause;

    private int[] defect_count;

    private String[] cf_name;

    private String[] cf_value;

    private int[] tag_id;

    private int[] ca_tag_id;

    public CamlineWcaSelected5Dto() {
    }

    public CamlineWcaSelected5Dto(int lds_id, String station_user, String author, int viol_comment_date,
                                  short viol_count, short ca_attr_nr, short exkey_recnum, short datkey_recnum,
                                  int tot_viol_count, int tot_attribute_count, int tot_cf_count, int tag_num,
                                  int ca_tag_num, String[] viol_comment, String[] parameter_name, long[] sample_id,
                                  int[] sample_date, int[] prio_viol_id, int[] ch_id, int[] ckc_id, String[] ch_state,
                                  String[] set_spc_flag, String[] spc_flag_extern, String[] spc_com_extern,
                                  int[] ca_id_selected, String[] ca_name, short[] ca_attr_num,
                                  short[] sample_viol_count, int[] prev_ca_id, int[] smp_defect_count,
                                  short[] smp_cf_count, int[] smp_tag_count, int[] ca_tag_count, String[] ca_attribute,
                                  short[] exkey_id, String[] exkey_name, String[] exkey_value, short[] datkey_id,
                                  String[] datkey_name, String[] datkey_value, int[] all_viol_id, String[] defect_type,
                                  String[] defect_location, String[] defect_cause, int[] defect_count, String[] cf_name,
                                  String[] cf_value, int[] tag_id, int[] ca_tag_id) {
        this.lds_id = lds_id;
        this.station_user = station_user;
        this.author = author;
        this.viol_comment_date = viol_comment_date;
        this.viol_count = viol_count;
        this.ca_attr_nr = ca_attr_nr;
        this.exkey_recnum = exkey_recnum;
        this.datkey_recnum = datkey_recnum;
        this.tot_viol_count = tot_viol_count;
        this.tot_attribute_count = tot_attribute_count;
        this.tot_cf_count = tot_cf_count;
        this.tag_num = tag_num;
        this.ca_tag_num = ca_tag_num;
        this.viol_comment = viol_comment;
        this.parameter_name = parameter_name;
        this.sample_id = sample_id;
        this.sample_date = sample_date;
        this.prio_viol_id = prio_viol_id;
        this.ch_id = ch_id;
        this.ckc_id = ckc_id;
        this.ch_state = ch_state;
        this.set_spc_flag = set_spc_flag;
        this.spc_flag_extern = spc_flag_extern;
        this.spc_com_extern = spc_com_extern;
        this.ca_id_selected = ca_id_selected;
        this.ca_name = ca_name;
        this.ca_attr_num = ca_attr_num;
        this.sample_viol_count = sample_viol_count;
        this.prev_ca_id = prev_ca_id;
        this.smp_defect_count = smp_defect_count;
        this.smp_cf_count = smp_cf_count;
        this.smp_tag_count = smp_tag_count;
        this.ca_tag_count = ca_tag_count;
        this.ca_attribute = ca_attribute;
        this.exkey_id = exkey_id;
        this.exkey_name = exkey_name;
        this.exkey_value = exkey_value;
        this.datkey_id = datkey_id;
        this.datkey_name = datkey_name;
        this.datkey_value = datkey_value;
        this.all_viol_id = all_viol_id;
        this.defect_type = defect_type;
        this.defect_location = defect_location;
        this.defect_cause = defect_cause;
        this.defect_count = defect_count;
        this.cf_name = cf_name;
        this.cf_value = cf_value;
        this.tag_id = tag_id;
        this.ca_tag_id = ca_tag_id;
    }

    @Override
    public String getMethod() {
        return "handleSpcTrigger";
    }

    @Override
    public String toString() {
        StringBuilder dbgBuf = new StringBuilder();
        int caAttrIdx = 0;
        int violIdx = 0;
        int defectIdx = 0;
        int attrIdx = 0;
        int smpTagIdx = 0;
        int caTagIdx = 0;
        int ekCount = exkey_recnum / viol_count;
        dbgBuf.append("\nlds_id = ").append(lds_id);//$NON-NLS-1$
        dbgBuf.append("\nstation_user = ").append(station_user);//$NON-NLS-1$
        dbgBuf.append("\nauthor = ").append(author);//$NON-NLS-1$
        dbgBuf.append("\nviol_comment_date = ").append(viol_comment_date);//$NON-NLS-1$
        dbgBuf.append(" (").append(new Date(viol_comment_date * 1000L)).append(")");//$NON-NLS-1$ //$NON-NLS-2$

        dbgBuf.append("\nviol_count = ").append(viol_count);//$NON-NLS-1$
        for (int i = 0; i < viol_count; i++) {
            dbgBuf.append("\n----------------------");//$NON-NLS-1$
            dbgBuf.append("\n    ch_id ckc_id  sample_id   smp_date prio param_name"); //$NON-NLS-1$
            String s = String.format("%n%1$10d %2$5d %3$10d %4$10d %5$4d %6$s", //$NON-NLS-1$
                                     Integer.valueOf(ch_id[i]), Integer.valueOf(ckc_id[i]), Long.valueOf(sample_id[i]),
                                     Integer.valueOf(sample_date[i]), Integer.valueOf(prio_viol_id[i]),
                                     parameter_name[i]);
            dbgBuf.append(s);
            s = "[" + i + "]=";//$NON-NLS-1$ //$NON-NLS-2$
            dbgBuf.append("\n viol_comment" + s + viol_comment[i]);//$NON-NLS-1$
            dbgBuf.append("\n ch_state" + s + ch_state[i]);//$NON-NLS-1$
            dbgBuf.append("\n set_spc_flag" + s + set_spc_flag[i]);//$NON-NLS-1$
            dbgBuf.append(" spc_flag_extern" + s + spc_flag_extern[i]);//$NON-NLS-1$
            dbgBuf.append(" spc_com_extern" + s + spc_com_extern[i]);//$NON-NLS-1$
            dbgBuf.append("\n ca_id_selected" + s + ca_id_selected[i]);//$NON-NLS-1$
            dbgBuf.append("\n ca_name" + s + ca_name[i]);//$NON-NLS-1$
            dbgBuf.append("\n ca_attr_num" + s + ca_attr_num[i]);//$NON-NLS-1$
            for (int j = 0; j < ca_attr_num[i]; j++) {
                dbgBuf.append(
                        "\n  ca_attribute[" + caAttrIdx + "]=" + ca_attribute[caAttrIdx++]);//$NON-NLS-1$ //$NON-NLS-2$
            }
            dbgBuf.append("\n ca_tag_count" + s + ca_tag_count[i]);//$NON-NLS-1$
            for (int j = 0; j < ca_tag_count[i]; j++) {
                dbgBuf.append("\n  tag_id[" + caTagIdx + "]=" + ca_tag_id[caTagIdx++]);//$NON-NLS-1$ //$NON-NLS-2$
            }
            dbgBuf.append("\n sample_viol_count" + s + sample_viol_count[i]);//$NON-NLS-1$
            for (int j = 0; j < sample_viol_count[i]; j++) {
                dbgBuf.append("\n  all_viol_id[" + violIdx + "]=" + all_viol_id[violIdx++]);//$NON-NLS-1$ //$NON-NLS-2$
            }
            dbgBuf.append("\n prev_ca_id" + s + prev_ca_id[i]);//$NON-NLS-1$
            dbgBuf.append("\n smp_attr_count" + s + smp_defect_count[i]);//$NON-NLS-1$
            for (int j = 0; j < smp_defect_count[i]; j++) {
                dbgBuf.append(
                        "\n  attribute_type[" + defectIdx + "]=" + defect_type[defectIdx]);//$NON-NLS-1$//$NON-NLS-2$
                dbgBuf.append("\n  attribute_location[" + defectIdx + "]=" + defect_location[defectIdx]);//$NON-NLS-1$
                // $NON-NLS-2$
                dbgBuf.append(
                        "\n  attribute_cause[" + defectIdx + "]=" + defect_cause[defectIdx]);//$NON-NLS-1$//$NON-NLS-2$
                dbgBuf.append(
                        "\n  attribute_count[" + defectIdx + "]=" + defect_count[defectIdx]);//$NON-NLS-1$//$NON-NLS-2$
                defectIdx++;
            }
            dbgBuf.append("\n smp_tag_count" + s + smp_tag_count[i]);//$NON-NLS-1$
            for (int j = 0; j < smp_tag_count[i]; j++) {
                dbgBuf.append("\n  tag_id[" + smpTagIdx + "]=" + tag_id[smpTagIdx]);//$NON-NLS-1$//$NON-NLS-2$
                smpTagIdx++;
            }
            dbgBuf.append("\n smp_cf_count" + s + smp_cf_count[i]);//$NON-NLS-1$
            for (int j = 0; j < smp_cf_count[i]; j++) {
                dbgBuf.append("\n  cf_name[" + attrIdx + "]=" + cf_name[attrIdx]);//$NON-NLS-1$//$NON-NLS-2$
                dbgBuf.append("\n  cf_value[" + attrIdx + "]=" + cf_value[attrIdx]);//$NON-NLS-1$//$NON-NLS-2$
                attrIdx++;
            }
            for (int k = 0; k < exkey_recnum; k++) {
                if (k < ekCount) {
                    dbgBuf.append(String.format("%n%1$3d %2$2d %3$-80s %4$s", //$NON-NLS-1$
                                                Integer.valueOf(k), Integer.valueOf(exkey_id[k]), exkey_value[k],
                                                exkey_name[k]));
                }
            }
        }

        dbgBuf.append("\nexkey_recnum = ").append(exkey_recnum);//$NON-NLS-1$
        dbgBuf.append(String.format("%nidx id %1$-80s %2$s", "value", "name")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$


        dbgBuf.append("\ndatkey_recnum = ").append(datkey_recnum);//$NON-NLS-1$
        dbgBuf.append(String.format("%nidx id %1$-80s %2$s", "value", "name")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        for (int i = 0; i < datkey_recnum; i++) {
            dbgBuf.append(String.format("%n%1$3d %2$2d %3$-80s %4$s", //$NON-NLS-1$
                                        Integer.valueOf(i), Integer.valueOf(datkey_id[i]), datkey_value[i],
                                        datkey_name[i]));
        }
        dbgBuf.append("\ntot_viol_count = ").append(tot_viol_count);//$NON-NLS-1$
        dbgBuf.append("\nca_attr_nr = ").append(ca_attr_nr);//$NON-NLS-1$
        dbgBuf.append("\ntot_attribute_count = ").append(tot_attribute_count);//$NON-NLS-1$
        dbgBuf.append("\ntot_cf_count = ").append(tot_cf_count);//$NON-NLS-1$

        return dbgBuf.toString();
    }

    @JsonIgnore
    public List<SpcHoldRequestDto> getSpcHoldReqeusts() {
        List<SpcHoldRequestDto> holdDtos = new ArrayList<>();

        String lotId = exkey_value[1];
        String equipmentId = exkey_value[15];
        String subEquipmentId = exkey_value[16];
        String lotIdList = datkey_value[12];
        for (int i = 0; i < viol_count; i++) {
            SpcHoldRequestDto holdDto = new SpcHoldRequestDto();
            holdDto.setLotId(lotId);
            holdDto.setEquipmentId(equipmentId);
            //SubEquipmentId若为'.'或者'-'将值置为空
            if (subEquipmentId.equals(SpcGatewayDataDto.POINT_CHAR) ||
                    subEquipmentId.equals(SpcGatewayDataDto.EMPTY_CHAR)) {
                holdDto.setSubEquipmentId("");
            } else {
                holdDto.setSubEquipmentId(subEquipmentId);
            }
            if (subEquipmentId.equals(SpcGatewayDataDto.POINT_CHAR) ||
                    subEquipmentId.equals(SpcGatewayDataDto.EMPTY_CHAR)) {
                holdDto.setLotIdList("");
            } else {
                holdDto.setLotIdList(lotIdList);
            }
            holdDto.setCaName(ca_name[i]);
            holdDto.setParameterName(parameter_name[i]);
            holdDto.setHoldReasons("SPACE TRRIGER HOLD");
            holdDto.setComment(viol_comment[i]);


            holdDtos.add(holdDto);
        }

        return holdDtos;
    }

    public int getLds_id() {
        return lds_id;
    }

    public void setLds_id(int lds_id) {
        this.lds_id = lds_id;
    }

    public String getStation_user() {
        return station_user;
    }

    public void setStation_user(String station_user) {
        this.station_user = station_user;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getViol_comment_date() {
        return viol_comment_date;
    }

    public void setViol_comment_date(int viol_comment_date) {
        this.viol_comment_date = viol_comment_date;
    }

    public short getViol_count() {
        return viol_count;
    }

    public void setViol_count(short viol_count) {
        this.viol_count = viol_count;
    }

    public short getCa_attr_nr() {
        return ca_attr_nr;
    }

    public void setCa_attr_nr(short ca_attr_nr) {
        this.ca_attr_nr = ca_attr_nr;
    }

    public short getExkey_recnum() {
        return exkey_recnum;
    }

    public void setExkey_recnum(short exkey_recnum) {
        this.exkey_recnum = exkey_recnum;
    }

    public short getDatkey_recnum() {
        return datkey_recnum;
    }

    public void setDatkey_recnum(short datkey_recnum) {
        this.datkey_recnum = datkey_recnum;
    }

    public int getTot_viol_count() {
        return tot_viol_count;
    }

    public void setTot_viol_count(int tot_viol_count) {
        this.tot_viol_count = tot_viol_count;
    }

    public int getTot_attribute_count() {
        return tot_attribute_count;
    }

    public void setTot_attribute_count(int tot_attribute_count) {
        this.tot_attribute_count = tot_attribute_count;
    }

    public int getTot_cf_count() {
        return tot_cf_count;
    }

    public void setTot_cf_count(int tot_cf_count) {
        this.tot_cf_count = tot_cf_count;
    }

    public int getTag_num() {
        return tag_num;
    }

    public void setTag_num(int tag_num) {
        this.tag_num = tag_num;
    }

    public int getCa_tag_num() {
        return ca_tag_num;
    }

    public void setCa_tag_num(int ca_tag_num) {
        this.ca_tag_num = ca_tag_num;
    }

    public String[] getViol_comment() {
        return viol_comment;
    }

    public void setViol_comment(String[] viol_comment) {
        this.viol_comment = viol_comment;
    }

    public String[] getParameter_name() {
        return parameter_name;
    }

    public void setParameter_name(String[] parameter_name) {
        this.parameter_name = parameter_name;
    }

    public long[] getSample_id() {
        return sample_id;
    }

    public void setSample_id(long[] sample_id) {
        this.sample_id = sample_id;
    }

    public int[] getSample_date() {
        return sample_date;
    }

    public void setSample_date(int[] sample_date) {
        this.sample_date = sample_date;
    }

    public int[] getPrio_viol_id() {
        return prio_viol_id;
    }

    public void setPrio_viol_id(int[] prio_viol_id) {
        this.prio_viol_id = prio_viol_id;
    }

    public int[] getCh_id() {
        return ch_id;
    }

    public void setCh_id(int[] ch_id) {
        this.ch_id = ch_id;
    }

    public int[] getCkc_id() {
        return ckc_id;
    }

    public void setCkc_id(int[] ckc_id) {
        this.ckc_id = ckc_id;
    }

    public String[] getCh_state() {
        return ch_state;
    }

    public void setCh_state(String[] ch_state) {
        this.ch_state = ch_state;
    }

    public String[] getSet_spc_flag() {
        return set_spc_flag;
    }

    public void setSet_spc_flag(String[] set_spc_flag) {
        this.set_spc_flag = set_spc_flag;
    }

    public String[] getSpc_flag_extern() {
        return spc_flag_extern;
    }

    public void setSpc_flag_extern(String[] spc_flag_extern) {
        this.spc_flag_extern = spc_flag_extern;
    }

    public String[] getSpc_com_extern() {
        return spc_com_extern;
    }

    public void setSpc_com_extern(String[] spc_com_extern) {
        this.spc_com_extern = spc_com_extern;
    }

    public int[] getCa_id_selected() {
        return ca_id_selected;
    }

    public void setCa_id_selected(int[] ca_id_selected) {
        this.ca_id_selected = ca_id_selected;
    }

    public String[] getCa_name() {
        return ca_name;
    }

    public void setCa_name(String[] ca_name) {
        this.ca_name = ca_name;
    }

    public short[] getCa_attr_num() {
        return ca_attr_num;
    }

    public void setCa_attr_num(short[] ca_attr_num) {
        this.ca_attr_num = ca_attr_num;
    }

    public short[] getSample_viol_count() {
        return sample_viol_count;
    }

    public void setSample_viol_count(short[] sample_viol_count) {
        this.sample_viol_count = sample_viol_count;
    }

    public int[] getPrev_ca_id() {
        return prev_ca_id;
    }

    public void setPrev_ca_id(int[] prev_ca_id) {
        this.prev_ca_id = prev_ca_id;
    }

    public int[] getSmp_defect_count() {
        return smp_defect_count;
    }

    public void setSmp_defect_count(int[] smp_defect_count) {
        this.smp_defect_count = smp_defect_count;
    }

    public short[] getSmp_cf_count() {
        return smp_cf_count;
    }

    public void setSmp_cf_count(short[] smp_cf_count) {
        this.smp_cf_count = smp_cf_count;
    }

    public int[] getSmp_tag_count() {
        return smp_tag_count;
    }

    public void setSmp_tag_count(int[] smp_tag_count) {
        this.smp_tag_count = smp_tag_count;
    }

    public int[] getCa_tag_count() {
        return ca_tag_count;
    }

    public void setCa_tag_count(int[] ca_tag_count) {
        this.ca_tag_count = ca_tag_count;
    }

    public String[] getCa_attribute() {
        return ca_attribute;
    }

    public void setCa_attribute(String[] ca_attribute) {
        this.ca_attribute = ca_attribute;
    }

    public short[] getExkey_id() {
        return exkey_id;
    }

    public void setExkey_id(short[] exkey_id) {
        this.exkey_id = exkey_id;
    }

    public String[] getExkey_name() {
        return exkey_name;
    }

    public void setExkey_name(String[] exkey_name) {
        this.exkey_name = exkey_name;
    }

    public String[] getExkey_value() {
        return exkey_value;
    }

    public void setExkey_value(String[] exkey_value) {
        this.exkey_value = exkey_value;
    }

    public short[] getDatkey_id() {
        return datkey_id;
    }

    public void setDatkey_id(short[] datkey_id) {
        this.datkey_id = datkey_id;
    }

    public String[] getDatkey_name() {
        return datkey_name;
    }

    public void setDatkey_name(String[] datkey_name) {
        this.datkey_name = datkey_name;
    }

    public String[] getDatkey_value() {
        return datkey_value;
    }

    public void setDatkey_value(String[] datkey_value) {
        this.datkey_value = datkey_value;
    }

    public int[] getAll_viol_id() {
        return all_viol_id;
    }

    public void setAll_viol_id(int[] all_viol_id) {
        this.all_viol_id = all_viol_id;
    }

    public String[] getDefect_type() {
        return defect_type;
    }

    public void setDefect_type(String[] defect_type) {
        this.defect_type = defect_type;
    }

    public String[] getDefect_location() {
        return defect_location;
    }

    public void setDefect_location(String[] defect_location) {
        this.defect_location = defect_location;
    }

    public String[] getDefect_cause() {
        return defect_cause;
    }

    public void setDefect_cause(String[] defect_cause) {
        this.defect_cause = defect_cause;
    }

    public int[] getDefect_count() {
        return defect_count;
    }

    public void setDefect_count(int[] defect_count) {
        this.defect_count = defect_count;
    }

    public String[] getCf_name() {
        return cf_name;
    }

    public void setCf_name(String[] cf_name) {
        this.cf_name = cf_name;
    }

    public String[] getCf_value() {
        return cf_value;
    }

    public void setCf_value(String[] cf_value) {
        this.cf_value = cf_value;
    }

    public int[] getTag_id() {
        return tag_id;
    }

    public void setTag_id(int[] tag_id) {
        this.tag_id = tag_id;
    }

    public int[] getCa_tag_id() {
        return ca_tag_id;
    }

    public void setCa_tag_id(int[] ca_tag_id) {
        this.ca_tag_id = ca_tag_id;
    }

}