package cn.estsh.i3plus.pojo.model.mes;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description : MES扭矩采集模型
 * @Reference :
 * @Author : siliter.yuan
 * @CreateDate : 2020-05-22 11:53
 * @Modify:
 **/
@Data
@NoArgsConstructor
public class TorqueCollectionModel implements Serializable {

    private static final long serialVersionUID = -6376845639746448495L;

    @ApiParam("Vin")
    private String vinCode;

    @ApiParam("项目代码")
    private String prodCfgTypeCode;

    @ApiParam("等级代码")
    private String gradeCode;

    @ApiParam("颜色代码")
    private String colorCode;

    @ApiParam("物料号")
    private String partNo;

    @ApiParam("物料名称")
    private String partName;

    @ApiParam("PEST编码1")
    private Integer pset1;

    @ApiParam("PEST编码2")
    private Integer pset2;

    @ApiParam("PEST编码3")
    private Integer pset3;

    @ApiParam("PEST编码4")
    private Integer pset4;

    @ApiParam("PEST编码5")
    private Integer pset5;

    @ApiParam("PEST编码6")
    private Integer pset6;

    @ApiParam("PEST编码7")
    private Integer pset7;

    @ApiParam("PEST编码8")
    private Integer pset8;

    @ApiParam("扭矩枪编号")
    private Integer torqueNo;

    @ApiParam("PEST号")
    private Integer psetNum;

    @ApiParam("PEST数量")
    private Integer psetCount;

    /**
     * 1-未采集， 2-已采集, 3-无需打扭矩
     */
    @ApiParam("扭矩采集状态")
    private Integer torqueStatus;

    /**
     * 1-未绑定，2-已绑定
     */
    @ApiParam("关键件绑定状态")
    private Integer bindKeyPartStatus;

    @ApiParam("扭矩值")
    private Integer torqueValue;

    @ApiParam("确认扫描次数")
    private Integer checkScanCount;

    @ApiParam("实际确认扫描次数")
    private Integer actualCheckScanCount;

    @ApiParam("组合码发送顺序")
    private Integer sendSeq;

    @ApiParam("黄枪规则")
    private Integer yellowGunRule;

    @ApiParam("是否截至顺序号")
    private Integer isEndSeq;

    @ApiParam("组合码")
    private String groupCode;

    @ApiParam("是否黄枪")
    private Integer isYellowGun;

    @ApiParam("应收合格数")
    private Double qualifiedCount;

    @ApiParam("实际合格数")
    private Double actualQualifiedCount;

    @ApiParam("是否已经发送了新的组合码")
    private boolean hasSendAsciiWhenYellow;

    @ApiParam("工步信息行颜色")
    private String color;

    @ApiParam("扭矩显示信息")
    private String torqueInfo;
    @ApiParam("扭矩颜色")
    private String torqueColor;

    @ApiParam("绑定关键件信息")
    private String bindPartKeyInfo;
    @ApiParam("绑定关键件颜色")
    private String bindPartKeyColor;

    @ApiParam("是否大枪")
    private Integer isPf;

    @ApiParam("psets总数")
    private Integer psetSum;

    @ApiParam("防错码")
    private String pokeYokeFix;

    @ApiParam("防错码长度")
    private String pokeYokeLength;

    private Map<String, PsetModel> psets = new LinkedHashMap<>();

    public TorqueCollectionModel(String vinCode) {
        this.vinCode = vinCode;
    }

    /**
     * 大枪查询结果构造方法
     *
     * @param vinCode
     * @param prodCfgTypeCode
     * @param gradeCode
     * @param colorCode
     * @param partNo
     * @param partName
     * @param torqueNo
     * @param checkScanCount
     * @param sendSeq
     * @param yellowGunRule
     * @param isEndSeq
     * @param groupCode
     */
    public TorqueCollectionModel(String vinCode, String prodCfgTypeCode, String gradeCode, String colorCode, String partNo,
                                 String partName, Integer torqueNo, Integer checkScanCount, Integer sendSeq,
                                 Integer yellowGunRule, Integer isEndSeq, String groupCode, Integer isPf, Double qualifiedCount,
                                 String pokeYokeFix, String pokeYokeLength) {
        this.vinCode = vinCode;
        this.prodCfgTypeCode = prodCfgTypeCode;
        this.gradeCode = gradeCode;
        this.colorCode = colorCode;
        this.partNo = partNo;
        this.partName = partName;
        this.torqueNo = torqueNo;
        this.checkScanCount = checkScanCount;
        this.sendSeq = sendSeq;
        this.yellowGunRule = yellowGunRule;
        this.isEndSeq = isEndSeq;
        this.groupCode = groupCode;
        this.isPf = isPf;
        this.qualifiedCount = qualifiedCount;
        this.pokeYokeFix = pokeYokeFix;
        this.pokeYokeLength = pokeYokeLength;
    }

    /**
     * 小枪结果数据构造方法
     *
     * @param vinCode
     * @param prodCfgTypeCode
     * @param gradeCode
     * @param colorCode
     * @param partNo
     * @param partName
     * @param pset1
     * @param pset2
     * @param pset3
     * @param pset4
     * @param pset5
     * @param pset6
     * @param pset7
     * @param pset8
     * @param torqueNo
     */
    public TorqueCollectionModel(String vinCode, String prodCfgTypeCode, String gradeCode,
                                 String colorCode, String partNo, String partName, Integer pset1, Integer pset2,
                                 Integer pset3, Integer pset4, Integer pset5, Integer pset6, Integer pset7, Integer pset8,
                                 Integer torqueNo, Integer sendSeq, Integer checkScanCount, String pokeYokeFix, String pokeYokeLength) {
        this.vinCode = vinCode;
        this.prodCfgTypeCode = prodCfgTypeCode;
        this.gradeCode = gradeCode;
        this.colorCode = colorCode;
        this.partNo = partNo;
        this.partName = partName;
        this.pset1 = pset1;
        this.pset2 = pset2;
        this.pset3 = pset3;
        this.pset4 = pset4;
        this.pset5 = pset5;
        this.pset6 = pset6;
        this.pset7 = pset7;
        this.pset8 = pset8;
        this.torqueNo = torqueNo;
        this.sendSeq = sendSeq;
        this.checkScanCount = checkScanCount;
        this.pokeYokeFix = pokeYokeFix;
        this.pokeYokeLength = pokeYokeLength;
        assemblePsets();
    }

    private void assemblePsets() {
        psets.put("pset1", new PsetModel("pset1", 1, this.pset1, 0, false));
        psets.put("pset2", new PsetModel("pset2", 2, this.pset2, 0, false));
        psets.put("pset3", new PsetModel("pset3", 3, this.pset3, 0, false));
        psets.put("pset4", new PsetModel("pset4", 4, this.pset4, 0, false));
        psets.put("pset5", new PsetModel("pset5", 5, this.pset5, 0, false));
        psets.put("pset6", new PsetModel("pset6", 6, this.pset6, 0, false));
        psets.put("pset7", new PsetModel("pset7", 7, this.pset7, 0, false));
        psets.put("pset8", new PsetModel("pset8", 8, this.pset8, 0, false));
    }

}
