pang.jiabao
4 天以前 c5698e42c67e32892424a1a94ed9e7b532f0f7b8
src/main/java/com/zy/common/model/LocTypeDto.java
@@ -1,7 +1,7 @@
package com.zy.common.model;
import com.core.exception.CoolException;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.utils.News;
import lombok.Data;
/**
@@ -19,17 +19,33 @@
    // 轻重类型{0:未知,1:轻库位,2:重库位}
    private Short locType3;
    private Integer siteId;
    public LocTypeDto() {
    }
    public LocTypeDto(Short locType1, Short locType2, Short locType3) {
        this.locType1 = locType1;
        this.locType2 = locType2;
        this.locType3 = locType3;
    }
    public LocTypeDto(StaProtocol staProtocol) {
        if (staProtocol.isHigh() == staProtocol.isLow()) {
            throw new CoolException("plc高低检测异常");
        if (staProtocol.isHigh() == staProtocol.isLow() || staProtocol.isChang() == staProtocol.isDuan()) {
                    News.error("plc高低/长短检测异常,high:{},low:{},chang:{},duan:{}",staProtocol.isHigh(),staProtocol.isLow(),staProtocol.isChang(),staProtocol.isDuan());
                    return;
        }
        if (staProtocol.isLow()) {
            this.locType1 = 1; // 低库位
        if (staProtocol.isHigh()) {
            this.locType1 = 2;
        } else {
            this.locType1 = 2; // 高库位
            this.locType1 = 1;
        }
        if (staProtocol.isChang()) {
            this.locType2 = 2; // 长库位
        } else {
            this.locType2 = 1; // 短库位
        }
    }
@@ -38,14 +54,14 @@
     */
    public static LocTypeDto process(StaProtocol staProtocol) {
        LocTypeDto dto = new LocTypeDto();
        if (staProtocol.isHigh() == staProtocol.isLow()) {
            throw new CoolException("plc高低检测异常");
        }
        if (staProtocol.isLow()) {
            dto.setLocType1((short) 1); // 低库位
        } else {
            dto.setLocType1((short) 2); // 高库位
        }
//        if (staProtocol.isHigh() == staProtocol.isLow()) {
//            throw new CoolException("plc高低检测异常");
//        }
//        if (staProtocol.isLow()) {
//            dto.setLocType1((short) 1); // 低库位
//        } else {
//            dto.setLocType1((short) 2); // 高库位
//        }
        return dto;
    }