|  |  |  | 
|---|
|  |  |  | package com.zy.core.model.protocol; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.BasCrnp; | 
|---|
|  |  |  | import com.zy.core.enums.*; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.SpringUtils; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasSte; | 
|---|
|  |  |  | import com.zy.asrs.service.BasSteService; | 
|---|
|  |  |  | import com.zy.core.enums.SteHisTaskStatusType; | 
|---|
|  |  |  | import com.zy.core.enums.SteLocaType; | 
|---|
|  |  |  | import com.zy.core.enums.SteStatusType; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 2020/8/7 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class SteProtocol { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public Short mode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机当前状态 | 
|---|
|  |  |  | * 0:空闲,无任务 | 
|---|
|  |  |  | * 1:取货定位中 | 
|---|
|  |  |  | * 2:取货中 | 
|---|
|  |  |  | * 3:取货完成,放货定位中 | 
|---|
|  |  |  | * 4:放货中 | 
|---|
|  |  |  | * 5:回原点中 | 
|---|
|  |  |  | * 6:反原点 | 
|---|
|  |  |  | * 7:库位移位 | 
|---|
|  |  |  | * 90:任务完成等待WCS确认 | 
|---|
|  |  |  | * 99:报警 | 
|---|
|  |  |  | IDLE(0, "空闲"), | 
|---|
|  |  |  | MOVING(1, "作业中"), | 
|---|
|  |  |  | SOS(2, "报警"), | 
|---|
|  |  |  | WAITING(3, "任务完成等待WCS确认"), | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short status; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 状态枚举 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public SteStatusType statusType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short taskNo = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 正在执行任务 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean execute; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务完成,等待WCS确认 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean waiting; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常码1 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer alarm; | 
|---|
|  |  |  | public Short alarm; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常码2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer alarm0; | 
|---|
|  |  |  | public Short alarm0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电池电量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short charge; | 
|---|
|  |  |  | public Float charge = 0.0F; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电池馈电     0,正常,1馈电 | 
|---|
|  |  |  | * 满电 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean fullCharge; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 低电量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean lowCharge; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电池馈电    0,欠电,1低电 2满电 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short feed; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前位置     1,近点,2远点,3A点,4B点 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short loca; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public SteLocaType locaType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 近点距离 | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前速度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Double speed; | 
|---|
|  |  |  | public Double speed = 0.0D; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 高低位 0,低位,1高位 | 
|---|
|  |  |  | 
|---|
|  |  |  | * 在轨道上 0不在,1在 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short track; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer taskNo = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务类型 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 过账指令状态 | 
|---|
|  |  |  | * 0初始 1执行完成 2删除 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short hisTaskStatus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public SteHisTaskStatusType hisTaskStatusType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 盘点数量 | 
|---|
|  |  |  | 
|---|
|  |  |  | this.status = SteStatusType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setLoca(Short loca){ | 
|---|
|  |  |  | this.loca = loca; | 
|---|
|  |  |  | this.locaType = SteLocaType.get(loca); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setLoca(SteLocaType type){ | 
|---|
|  |  |  | this.locaType = type; | 
|---|
|  |  |  | this.loca = SteLocaType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setHisTaskStatus(Short hisTaskStatus){ | 
|---|
|  |  |  | this.hisTaskStatus = hisTaskStatus; | 
|---|
|  |  |  | this.hisTaskStatusType = SteHisTaskStatusType.get(hisTaskStatus); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setHisTaskStatus(SteHisTaskStatusType type){ | 
|---|
|  |  |  | this.hisTaskStatusType = type; | 
|---|
|  |  |  | this.hisTaskStatus = SteHisTaskStatusType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 最近一次入出库类型 | 
|---|
|  |  |  | *       I:入库 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String lastIo = "I"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String pakMk = "-"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public BasCrnp toSqlModel(BasCrnp basCrnp){ | 
|---|
|  |  |  | public BasSte toSqlModel(BasSte basSte){ | 
|---|
|  |  |  | if (alarm!=null) { | 
|---|
|  |  |  | basCrnp.setCrnErr(alarm.longValue()); | 
|---|
|  |  |  | basSte.setSteErr(alarm.longValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | basCrnp.setWrkNo(taskNo); | 
|---|
|  |  |  | return basCrnp; | 
|---|
|  |  |  | basSte.setWrkNo(taskNo.intValue()); | 
|---|
|  |  |  | //        if (basSte.getPakMk().equals("N")) { | 
|---|
|  |  |  | //            if (!Cools.isEmpty(row)) { | 
|---|
|  |  |  | //                basSte.setRow(row.intValue()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if (!Cools.isEmpty(bay)) { | 
|---|
|  |  |  | //                basSte.setBay(bay.intValue()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if (!Cools.isEmpty(lev)) { | 
|---|
|  |  |  | //                basSte.setLev(lev.intValue()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | return basSte; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 是否处于空闲待命状态 | 
|---|
|  |  |  | public Boolean isIdle() { | 
|---|
|  |  |  | boolean res = this.statusType.equals(SteStatusType.IDLE) | 
|---|
|  |  |  | && this.pakMk.equals("N") | 
|---|
|  |  |  | && !isAlarm(); | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 电量 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String chargeLine = SpringUtils.getBean(BasSteService.class).selectById(this.steNo).getChargeLine(); | 
|---|
|  |  |  | return charge > Float.parseFloat(chargeLine); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("fail", e); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 是否处于报警状态 | 
|---|
|  |  |  | public Boolean isAlarm() { | 
|---|
|  |  |  | return this.alarm > 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|