|  |  |  | 
|---|
|  |  |  | package com.zy.core.model.protocol; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.common.utils.News; | 
|---|
|  |  |  | 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 { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private Short steNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * -1 = 离线 | 
|---|
|  |  |  | * 1 = 联机模式 | 
|---|
|  |  |  | * 0 = 脱机模式 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | public SteStatusType statusType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short taskNo = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 正在执行任务 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean execute; | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常码1 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer alarm; | 
|---|
|  |  |  | public Short alarm; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常码2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer alarm0; | 
|---|
|  |  |  | public Short alarm0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电池电量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short charge; | 
|---|
|  |  |  | public Float charge = 0.0F; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 满电 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short feed; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前位置     1,近点,2远点,3A点,4B点 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前速度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Double speed; | 
|---|
|  |  |  | public Double speed = 0.0D; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 高低位 0,低位,1高位 | 
|---|
|  |  |  | 
|---|
|  |  |  | * 在轨道上 0不在,1在 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short track; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer taskNo = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务类型 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short crnAllowRun; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 充电状态  1:在充电;0:不在充电 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Short chargeStatus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 入库取空 | 
|---|
|  |  |  | private Boolean inEmpty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 出库取空 | 
|---|
|  |  |  | private Boolean outEmpty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setStatus(Short status){ | 
|---|
|  |  |  | this.status = status; | 
|---|
|  |  |  | this.statusType = SteStatusType.get(status); | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String lastIo = "I"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String pakMk = "-"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public BasSte toSqlModel(BasSte basSte){ | 
|---|
|  |  |  | if (alarm!=null) { | 
|---|
|  |  |  | basSte.setSteErr(alarm.longValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | basSte.setWrkNo(taskNo); | 
|---|
|  |  |  | 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() | 
|---|
|  |  |  | && this.chargeStatus == 0 | 
|---|
|  |  |  | && isEnable() | 
|---|
|  |  |  | && this.getMode()==1 | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 电量 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String chargeLine = SpringUtils.getBean(BasSteService.class).selectById(this.steNo).getChargeLine(); | 
|---|
|  |  |  | return charge > Float.parseFloat(chargeLine); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | News.error("fail", e); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 是否处于报警状态 | 
|---|
|  |  |  | public Boolean isAlarm() { | 
|---|
|  |  |  | return this.alarm > 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Boolean isEnable() { | 
|---|
|  |  |  | if (Cools.isEmpty(row)) { | 
|---|
|  |  |  | if (row == 0) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(bay)) { | 
|---|
|  |  |  | if (bay == 0) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(lev)) { | 
|---|
|  |  |  | if (lev == 0) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|