| | |
| | | import com.zy.asrs.domain.vo.CommandLogVo; |
| | | import com.zy.asrs.domain.vo.CrnMsgTableVo; |
| | | import com.zy.asrs.domain.vo.CrnStateTableVo; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnModeType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.CrnThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | * 堆垛机接口 |
| | | * Created by vincent on 2020-06-01 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/crn") |
| | | public class CrnController { |
| | | |
| | | public static AtomicInteger integer = new AtomicInteger(); |
| | | private static AtomicInteger integer = new AtomicInteger(); |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @ManagerAuth(memo = "进行中的命令") |
| | | @PostMapping("/command/ongoing") |
| | |
| | | @ManagerAuth(memo = "堆垛机信息表") |
| | | public R crnStateTable(){ |
| | | List<CrnStateTableVo> list = new ArrayList<>(); |
| | | for (int i=1;i<=4;i++){ |
| | | CrnStateTableVo vo = new CrnStateTableVo(String.valueOf(i), CrnStatusType.AUTO, "正常", "有物", "99", "3", "中位", "18233", "422", "0", "1204", "关闭", "0"); |
| | | if (integer.get()%5 == 0) { |
| | | vo.setWorkNo("0000"); |
| | | } else { |
| | | vo.setWorkNo("9998"); |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | if (crnThread == null) { |
| | | log.error("{}号堆垛机连接失败", crn.getId()); |
| | | continue; |
| | | } |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | log.error("{}号堆垛机连接失败", crn.getId()); |
| | | continue; |
| | | } |
| | | // 表格行 |
| | | CrnStateTableVo vo = new CrnStateTableVo(); |
| | | vo.setCrnNo(crn.getId()); // 堆垛机号 |
| | | vo.setWorkNo(crnProtocol.getTaskNo()); // 任务号 |
| | | if (crnProtocol.getTaskNo()>0) { |
| | | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | | vo.setStatusType(CrnStatusType.process(wrkMast.getIoType())); // 模式状态 |
| | | } |
| | | } else { |
| | | vo.setStatusType(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.AUTO: CrnStatusType.UN_AUTO); // 模式状态 |
| | | } |
| | | vo.setStatus(crnProtocol.getStatusType().desc); // 状态 |
| | | vo.setWarn(""); // 报警 todo |
| | | vo.setLoading(crnProtocol.getLoaded()==1?"Y":"N"); // 有物 |
| | | vo.setBay(crnProtocol.getBay()); // 列 |
| | | vo.setLev(crnProtocol.getLevel()); // 层 |
| | | vo.setForkOffset(crnProtocol.getForkPosType().desc); // 货叉位置 |
| | | vo.setLiftPos(crnProtocol.getLiftPosType().desc); // 载货台位置 |
| | | list.add(vo); |
| | | } |
| | | integer.getAndIncrement(); |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | |
| | | package com.zy.asrs.domain.vo; |
| | | |
| | | import com.zy.asrs.domain.enums.CrnStatusType; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2020-06-02 |
| | | */ |
| | | @Data |
| | | public class CrnStateTableVo { |
| | | |
| | | // 堆垛机号 |
| | | private String crnNo; |
| | | private Integer crnNo; |
| | | |
| | | // 模式 |
| | | private CrnStatusType type; |
| | | private CrnStatusType statusType; |
| | | |
| | | // 报警 |
| | | private String warn; |
| | |
| | | private String loading; |
| | | |
| | | // 列 |
| | | private String bay; |
| | | private Short bay; |
| | | |
| | | // 层 |
| | | private String lev; |
| | | private Short lev; |
| | | |
| | | // 货叉位置 |
| | | private String forkOffset; |
| | | |
| | | // 载货台位置 |
| | | private String liftPos; |
| | | |
| | | // 列坐标 |
| | | private String bayCoor; |
| | |
| | | private String complete; |
| | | |
| | | // 任务号 |
| | | private String workNo; |
| | | private Short workNo; |
| | | |
| | | // 状态 |
| | | private String status; |
| | |
| | | // 报警码 |
| | | private String warnCode; |
| | | |
| | | public CrnStateTableVo() { |
| | | } |
| | | |
| | | public CrnStateTableVo(String crnNo, CrnStatusType type, String warn, String loading, String bay, String lev, String forkOffset, String bayCoor, String levCoor, String complete, String workNo, String status, String warnCode) { |
| | | this.crnNo = crnNo; |
| | | this.type = type; |
| | | this.warn = warn; |
| | | this.loading = loading; |
| | | this.bay = bay; |
| | | this.lev = lev; |
| | | this.forkOffset = forkOffset; |
| | | this.bayCoor = bayCoor; |
| | | this.levCoor = levCoor; |
| | | this.complete = complete; |
| | | this.workNo = workNo; |
| | | this.status = status; |
| | | this.warnCode = warnCode; |
| | | } |
| | | |
| | | public String getCrnNo() { |
| | | return crnNo; |
| | | } |
| | | |
| | | public void setCrnNo(String crnNo) { |
| | | this.crnNo = crnNo; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type.getDesc(); |
| | | } |
| | | |
| | | public void setType(CrnStatusType type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getWarn() { |
| | | return warn; |
| | | } |
| | | |
| | | public void setWarn(String warn) { |
| | | this.warn = warn; |
| | | } |
| | | |
| | | public String getLoading() { |
| | | return loading; |
| | | } |
| | | |
| | | public void setLoading(String loading) { |
| | | this.loading = loading; |
| | | } |
| | | |
| | | public String getBay() { |
| | | return bay; |
| | | } |
| | | |
| | | public void setBay(String bay) { |
| | | this.bay = bay; |
| | | } |
| | | |
| | | public String getLev() { |
| | | return lev; |
| | | } |
| | | |
| | | public void setLev(String lev) { |
| | | this.lev = lev; |
| | | } |
| | | |
| | | public String getForkOffset() { |
| | | return forkOffset; |
| | | } |
| | | |
| | | public void setForkOffset(String forkOffset) { |
| | | this.forkOffset = forkOffset; |
| | | } |
| | | |
| | | public String getBayCoor() { |
| | | return bayCoor; |
| | | } |
| | | |
| | | public void setBayCoor(String bayCoor) { |
| | | this.bayCoor = bayCoor; |
| | | } |
| | | |
| | | public String getLevCoor() { |
| | | return levCoor; |
| | | } |
| | | |
| | | public void setLevCoor(String levCoor) { |
| | | this.levCoor = levCoor; |
| | | } |
| | | |
| | | public String getComplete() { |
| | | return complete; |
| | | } |
| | | |
| | | public void setComplete(String complete) { |
| | | this.complete = complete; |
| | | } |
| | | |
| | | public String getWorkNo() { |
| | | return workNo; |
| | | } |
| | | |
| | | public void setWorkNo(String workNo) { |
| | | this.workNo = workNo; |
| | | } |
| | | |
| | | public String getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getWarnCode() { |
| | | return warnCode; |
| | | } |
| | | |
| | | public void setWarnCode(String warnCode) { |
| | | this.warnCode = warnCode; |
| | | } |
| | | } |
| | |
| | | |
| | | public enum CrnForkPosType { |
| | | |
| | | HOME(1), // 货叉原位 |
| | | LEFT(2), // 货叉在左侧 |
| | | RIGHT(0), // 货叉在右侧 |
| | | HOME(0, "货叉原位"), // 货叉原位 |
| | | LEFT(1, "货叉在左侧"), // 货叉在左侧 |
| | | RIGHT(2, "货叉在右侧"), // 货叉在右侧 |
| | | ; |
| | | |
| | | public Integer id; |
| | | CrnForkPosType(Integer id) { |
| | | public String desc; |
| | | CrnForkPosType(Integer id, String desc) { |
| | | this.id = id; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public static CrnForkPosType get(Short id) { |
| | |
| | | |
| | | public enum CrnLiftPosType { |
| | | |
| | | DOWN(1), // 下定位 |
| | | UP(2), // 上定位 |
| | | NONE(0), // 不在定位 |
| | | DOWN(1, "下定位"), // 下定位 |
| | | UP(2, "上定位"), // 上定位 |
| | | NONE(0, "不在定位"), // 不在定位 |
| | | ; |
| | | |
| | | public Integer id; |
| | | CrnLiftPosType(Integer id) { |
| | | public String desc; |
| | | CrnLiftPosType(Integer id, String desc) { |
| | | this.id = id; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public static CrnLiftPosType get(Short id) { |
| | |
| | | <thead> |
| | | <tr> |
| | | <th>堆垛机</th> |
| | | <th>任务号</th> |
| | | <th>模式</th> |
| | | <th>状态</th> |
| | | <th>报警</th> |
| | | <th>有物</th> |
| | | <th>列</th> |
| | | <th>层</th> |
| | | <th>货叉位置</th> |
| | | <th>列坐标</th> |
| | | <th>层坐标</th> |
| | | <th>完成</th> |
| | | <th>任务号</th> |
| | | <th>状态</th> |
| | | <th>报警码</th> |
| | | <th>载货台位置</th> |
| | | </tr> |
| | | </thead> |
| | | <tbody> |
| | |
| | | for (var i=1;i<=table.length;i++){ |
| | | var tr = tableEl.find("tr").eq(i); |
| | | setVal(tr.children("td").eq(0), table[i-1].crnNo); |
| | | setVal(tr.children("td").eq(1), table[i-1].type); |
| | | setVal(tr.children("td").eq(2), table[i-1].warn); |
| | | setVal(tr.children("td").eq(3), table[i-1].loading); |
| | | setVal(tr.children("td").eq(4), table[i-1].bay); |
| | | setVal(tr.children("td").eq(5), table[i-1].lev); |
| | | setVal(tr.children("td").eq(6), table[i-1].forkOffset); |
| | | setVal(tr.children("td").eq(7), table[i-1].bayCoor); |
| | | setVal(tr.children("td").eq(8), table[i-1].levCoor); |
| | | setVal(tr.children("td").eq(9), table[i-1].complete); |
| | | setVal(tr.children("td").eq(10), table[i-1].workNo); |
| | | setVal(tr.children("td").eq(11), table[i-1].status); |
| | | setVal(tr.children("td").eq(12), table[i-1].warnCode); |
| | | setVal(tr.children("td").eq(1), table[i-1].workNo); |
| | | setVal(tr.children("td").eq(2), table[i-1].statusType); |
| | | setVal(tr.children("td").eq(3), table[i-1].status); |
| | | setVal(tr.children("td").eq(4), table[i-1].warn); |
| | | setVal(tr.children("td").eq(5), table[i-1].loading); |
| | | setVal(tr.children("td").eq(6), table[i-1].bay); |
| | | setVal(tr.children("td").eq(7), table[i-1].lev); |
| | | setVal(tr.children("td").eq(8), table[i-1].forkOffset); |
| | | setVal(tr.children("td").eq(9), table[i-1].liftPos); |
| | | } |
| | | } else if (res.code === 403){ |
| | | window.location.href = baseUrl+"/login"; |
| | |
| | | var html = ""; |
| | | for (var i = 0; i < line; i ++){ |
| | | html += " <tr>\n" + |
| | | " <td></td>\n" + |
| | | " <td></td>\n" + |
| | | " <td></td>\n" + |
| | | " <td></td>\n" + |
| | | " <td></td>\n" + |
| | | " <td></td>\n" + |