| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.param.CrnCommandTakeParam; |
| | | import com.zy.asrs.domain.vo.CrnStateTableVo; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasCrnpErr; |
| | |
| | | import com.zy.asrs.service.BasCrnpErrService; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnModeType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | 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.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | |
| | | @PostMapping("/table/crn/state") |
| | | @ManagerAuth(memo = "堆垛机信息表") |
| | | public R crnStateTable(){ |
| | | public R crnStateTable() { |
| | | List<CrnStateTableVo> list = new ArrayList<>(); |
| | | List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); |
| | | for (BasCrnp basCrnp : crnps) { |
| | |
| | | vo.setWorkNo(crnProtocol.getTaskNo()); // 任务号 |
| | | vo.setMode(crnProtocol.getModeType().desc); // 模式状态 |
| | | vo.setStatus(crnProtocol.getStatusType().desc); // 状态 |
| | | vo.setLoading(crnProtocol.getLoaded()==1?"有物":"无物"); // 有物 |
| | | vo.setLoading(crnProtocol.getLoaded() == 1 ? "有物" : "无物"); // 有物 |
| | | vo.setBay(crnProtocol.getBay()); // 列 |
| | | vo.setLev(crnProtocol.getLevel()); // 层 |
| | | vo.setForkOffset(crnProtocol.getForkPosType().desc); // 货叉位置 |
| | | vo.setLiftPos(crnProtocol.getLiftPosType().desc); |
| | | vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位"); |
| | | vo.setWalkPos(crnProtocol.getWalkPos() == 1 ? "不在定位" : "在定位"); |
| | | vo.setXspeed(crnProtocol.getXSpeed()); // 走行速度(m/min) |
| | | vo.setYspeed(crnProtocol.getYSpeed()); // 升降速度(m/min) |
| | | vo.setZspeed(crnProtocol.getZSpeed()); // 叉牙速度(m/min) |
| | |
| | | vo.setDeviceStatus("AUTO"); |
| | | } |
| | | |
| | | if (crnProtocol.getTaskNo()>0) { |
| | | if (crnProtocol.getTaskNo() > 0) { |
| | | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | | vo.setSourceStaNo(String.valueOf(wrkMast.getSourceStaNo())); // 源站 |
| | |
| | | vo.setWarnCode(String.valueOf(crnProtocol.getAlarm())); |
| | | if (crnProtocol.getAlarm() > 0) { |
| | | BasCrnpErr crnError = basCrnpErrService.selectById(crnProtocol.getAlarm()); |
| | | vo.setAlarm(crnError==null?"未知异常":crnError.getErrName()); |
| | | vo.setAlarm(crnError == null ? "未知异常" : crnError.getErrName()); |
| | | vo.setDeviceStatus("ERROR"); |
| | | } |
| | | } |
| | |
| | | |
| | | @PostMapping("/output/site") |
| | | @ManagerAuth(memo = "堆垛机报文日志输出") |
| | | public R crnOutput(){ |
| | | public R crnOutput() { |
| | | StringBuilder str = new StringBuilder(); |
| | | String s; |
| | | int i = 0; |
| | | while((s = OutputQueue.CRN.poll()) != null && i <=10) { |
| | | while ((s = OutputQueue.CRN.poll()) != null && i <= 10) { |
| | | str.append("\n").append(s); |
| | | i++; |
| | | } |
| | | return R.ok().add(str.toString()); |
| | | } |
| | | |
| | | @PostMapping("/command/take") |
| | | public R crnCommandTake(@RequestBody CrnCommandTakeParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("缺少参数"); |
| | | } |
| | | |
| | | Integer crnNo = param.getCrnNo(); |
| | | String sourceLocNo = param.getSourceLocNo(); |
| | | String targetLocNo = param.getTargetLocNo(); |
| | | |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo); |
| | | if (crnThread == null) { |
| | | return R.error("线程不存在"); |
| | | } |
| | | |
| | | CrnCommand command = crnThread.getPickAndPutCommand(sourceLocNo, targetLocNo, 9999, crnNo); |
| | | MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/command/move") |
| | | public R crnCommandMove(@RequestBody CrnCommandTakeParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("缺少参数"); |
| | | } |
| | | |
| | | Integer crnNo = param.getCrnNo(); |
| | | String targetLocNo = param.getTargetLocNo(); |
| | | |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo); |
| | | if (crnThread == null) { |
| | | return R.error("线程不存在"); |
| | | } |
| | | |
| | | CrnCommand command = crnThread.getMoveCommand(targetLocNo, 9999, crnNo); |
| | | MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/command/taskComplete") |
| | | public R crnCommandTaskComplete(@RequestBody CrnCommandTakeParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("缺少参数"); |
| | | } |
| | | |
| | | Integer crnNo = param.getCrnNo(); |
| | | |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo); |
| | | if (crnThread == null) { |
| | | return R.error("线程不存在"); |
| | | } |
| | | |
| | | CrnCommand command = crnThread.getResetCommand(crnNo); |
| | | MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command)); |
| | | return R.ok(); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.zy.asrs.domain.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class CrnCommandTakeParam { |
| | | |
| | | private Integer crnNo; |
| | | |
| | | private String sourceLocNo; |
| | | |
| | | private String targetLocNo; |
| | | |
| | | } |
| | |
| | | |
| | | public class Utils { |
| | | |
| | | private static final String LOC_NO_FLAG = "-"; |
| | | private static final DecimalFormat fmt = new DecimalFormat("##0.00"); |
| | | |
| | | public static float scale(Float f){ |
| | |
| | | */ |
| | | public static int getRow(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(0, 2)); |
| | | String[] split = locNo.split(LOC_NO_FLAG); |
| | | return Integer.parseInt(split[0]); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | |
| | | */ |
| | | public static int getBay(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(2, 5)); |
| | | String[] split = locNo.split(LOC_NO_FLAG); |
| | | return Integer.parseInt(split[1]); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | |
| | | */ |
| | | public static int getLev(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(5, 7)); |
| | | String[] split = locNo.split(LOC_NO_FLAG); |
| | | return Integer.parseInt(split[2]); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | public static String getLocNo(Number row, Number bay, Number lev) { |
| | | return zerofill(String.valueOf(row), 2) + zerofill(String.valueOf(bay), 3) + zerofill(String.valueOf(lev), 2); |
| | | return row + LOC_NO_FLAG + bay + LOC_NO_FLAG + lev; |
| | | } |
| | | |
| | | public static boolean isJSON(String value) { |
| File was renamed from src/main/java/com/zy/core/network/ZyCrnConnectThread.java |
| | |
| | | import com.zy.core.network.real.ZyCrnRealConnect; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | |
| | | /** |
| | | * 连接驱动 |
| | | */ |
| | | @Slf4j |
| | | public class ZyCrnConnectThread implements ThreadHandler{ |
| | | public class ZyCrnConnectDriver implements ThreadHandler{ |
| | | |
| | | private boolean connected = false; |
| | | private SiemensS7Net siemensNet; |
| | | private DeviceConfig deviceConfig; |
| | | private ZyCrnConnectApi zyCrnConnectApi; |
| | | |
| | | public ZyCrnConnectThread(SiemensS7Net siemensS7Net, DeviceConfig deviceConfig) { |
| | | public ZyCrnConnectDriver(SiemensS7Net siemensS7Net, DeviceConfig deviceConfig) { |
| | | this.siemensNet = siemensS7Net; |
| | | this.deviceConfig = deviceConfig; |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.core.enums.CrnStatusType; |
| | | import com.zy.core.enums.CrnTaskModeType; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.network.api.ZyCrnConnectApi; |
| | | import com.zy.core.network.entity.ZyCrnStatusEntity; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | |
| | | public class ZyCrnFakeConnect implements ZyCrnConnectApi { |
| | | |
| | | private ZyCrnStatusEntity crnStatus; |
| | | private DeviceConfig deviceConfig; |
| | | private final ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | |
| | | public ZyCrnFakeConnect(DeviceConfig deviceConfig) { |
| | | this.deviceConfig = deviceConfig; |
| | |
| | | @Override |
| | | public CommandResponse sendCommand(CrnCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (command.getTaskMode().intValue() == CrnTaskModeType.LOC_MOVE.id) { |
| | | //取放货 |
| | | executor.submit(() -> commandTake(command)); |
| | | } else if (command.getTaskMode().intValue() == CrnTaskModeType.CRN_MOVE.id) { |
| | | //移动 |
| | | executor.submit(() -> commandMove(command)); |
| | | } else if (command.getTaskMode().intValue() == CrnTaskModeType.NONE.id) { |
| | | //复位 |
| | | executor.submit(() -> commandTaskComplete(command)); |
| | | } |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | |
| | | private void commandTaskComplete(CrnCommand command) { |
| | | this.crnStatus.setTaskNo(0); |
| | | this.crnStatus.setStatus(CrnStatusType.IDLE.id); |
| | | } |
| | | |
| | | private void commandMove(CrnCommand command) { |
| | | int destinationPosX = command.getDestinationPosX().intValue(); |
| | | int destinationPosY = command.getDestinationPosY().intValue(); |
| | | int destinationPosZ = command.getDestinationPosZ().intValue(); |
| | | int taskMode = command.getTaskMode().intValue(); |
| | | int taskNo = command.getTaskNo().intValue(); |
| | | |
| | | this.crnStatus.setTaskNo(taskNo); |
| | | this.crnStatus.setStatus(CrnStatusType.MOVING.id); |
| | | moveY(this.crnStatus.getBay(), destinationPosY); |
| | | moveZ(this.crnStatus.getLevel(), destinationPosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.WAITING.id); |
| | | } |
| | | |
| | | private void commandTake(CrnCommand command) { |
| | | int sourcePosX = command.getSourcePosX().intValue(); |
| | | int sourcePosY = command.getSourcePosY().intValue(); |
| | | int sourcePosZ = command.getSourcePosZ().intValue(); |
| | | int destinationPosX = command.getDestinationPosX().intValue(); |
| | | int destinationPosY = command.getDestinationPosY().intValue(); |
| | | int destinationPosZ = command.getDestinationPosZ().intValue(); |
| | | int taskMode = command.getTaskMode().intValue(); |
| | | int taskNo = command.getTaskNo().intValue(); |
| | | |
| | | this.crnStatus.setTaskNo(taskNo); |
| | | this.crnStatus.setStatus(CrnStatusType.FETCH_MOVING.id); |
| | | moveY(this.crnStatus.getBay(), sourcePosY); |
| | | moveZ(this.crnStatus.getLevel(), sourcePosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.FETCHING.id); |
| | | try { |
| | | Thread.sleep(2000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | this.crnStatus.setLoaded(1); |
| | | this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id); |
| | | moveY(this.crnStatus.getBay(), destinationPosY); |
| | | moveZ(this.crnStatus.getLevel(), destinationPosZ); |
| | | this.crnStatus.setStatus(CrnStatusType.PUTTING.id); |
| | | try { |
| | | Thread.sleep(2000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | this.crnStatus.setLoaded(0); |
| | | this.crnStatus.setStatus(CrnStatusType.WAITING.id); |
| | | } |
| | | |
| | | private void moveZ(int sourcePosZ, int destinationPosZ) { |
| | | if(destinationPosZ - sourcePosZ > 0) { |
| | | int moveLength = destinationPosZ - sourcePosZ; |
| | | int initSourcePosZ = sourcePosZ; |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosZ++; |
| | | this.crnStatus.setLevel(initSourcePosZ); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else { |
| | | int moveLength = sourcePosZ - destinationPosZ; |
| | | int initSourcePosZ = sourcePosZ; |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosZ--; |
| | | this.crnStatus.setLevel(initSourcePosZ); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void moveY(int sourcePosY, int destinationPosY) { |
| | | if(destinationPosY - sourcePosY > 0) { |
| | | int moveLength = destinationPosY - sourcePosY; |
| | | int initSourcePosY = sourcePosY; |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosY++; |
| | | this.crnStatus.setBay(initSourcePosY); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else { |
| | | int moveLength = sourcePosY - destinationPosY; |
| | | int initSourcePosY = sourcePosY; |
| | | for(int i = 0; i < moveLength; i++) { |
| | | initSourcePosY--; |
| | | this.crnStatus.setBay(initSourcePosY); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | CrnCommand getPickAndPutCommand(String sourceLocNo, String targetLocNo, Integer taskNo, Integer crnNo);//取放货 |
| | | |
| | | CrnCommand getMoveCommand(String sourceLocNo, String targetLocNo, Integer taskNo, Integer crnNo);//移动 |
| | | CrnCommand getMoveCommand(String targetLocNo, Integer taskNo, Integer crnNo);//移动 |
| | | |
| | | CrnCommand getResetCommand(Integer crnNo);//复位 |
| | | |
| | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.CrnTaskModeType; |
| | |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.network.DeviceConnectPool; |
| | | import com.zy.core.network.ZyCrnConnectThread; |
| | | import com.zy.core.network.ZyCrnConnectDriver; |
| | | import com.zy.core.network.entity.ZyCrnStatusEntity; |
| | | import com.zy.core.thread.CrnThread; |
| | | import lombok.Data; |
| | |
| | | |
| | | private DeviceConfig deviceConfig; |
| | | private RedisUtil redisUtil; |
| | | private ZyCrnConnectThread zyCrnConnectThread; |
| | | private ZyCrnConnectDriver zyCrnConnectDriver; |
| | | private CrnProtocol crnProtocol; |
| | | private boolean resetFlag = false; |
| | | |
| | |
| | | @Override |
| | | public boolean connect() { |
| | | SiemensS7Net siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, deviceConfig.getIp()); |
| | | zyCrnConnectThread = new ZyCrnConnectThread(siemensS7Net, deviceConfig); |
| | | new Thread(zyCrnConnectThread).start(); |
| | | DeviceConnectPool.put(SlaveType.Crn, deviceConfig.getDeviceNo(), zyCrnConnectThread); |
| | | zyCrnConnectDriver = new ZyCrnConnectDriver(siemensS7Net, deviceConfig); |
| | | new Thread(zyCrnConnectDriver).start(); |
| | | DeviceConnectPool.put(SlaveType.Crn, deviceConfig.getDeviceNo(), zyCrnConnectDriver); |
| | | return true; |
| | | } |
| | | |
| | |
| | | * 读取状态 |
| | | */ |
| | | private void readStatus(){ |
| | | ZyCrnStatusEntity crnStatus = zyCrnConnectThread.getStatus(); |
| | | ZyCrnStatusEntity crnStatus = zyCrnConnectDriver.getStatus(); |
| | | if (crnStatus == null) { |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort())); |
| | | News.error("SiemensCrn"+" - 5"+" - 读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()); |
| | |
| | | |
| | | @Override |
| | | public void close() { |
| | | zyCrnConnectThread.close(); |
| | | zyCrnConnectDriver.close(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CrnCommand getMoveCommand(String sourceLocNo, String targetLocNo, Integer taskNo, Integer crnNo) { |
| | | public CrnCommand getMoveCommand(String targetLocNo, Integer taskNo, Integer crnNo) { |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(crnNo); // 堆垛机编号 |
| | | crnCommand.setTaskNo(taskNo.shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.CRN_MOVE.id.shortValue()); // 任务模式: 堆垛机移动 |
| | | crnCommand.setSourcePosX((short) Utils.getRow(sourceLocNo)); // 源库位排 |
| | | crnCommand.setSourcePosY((short) Utils.getBay(sourceLocNo)); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) Utils.getLev(sourceLocNo)); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | crnCommand.setDestinationPosX((short) Utils.getRow(targetLocNo)); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) Utils.getBay(targetLocNo)); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) Utils.getLev(targetLocNo)); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); // 任务确认 |
| | | return crnCommand; |
| | | } |
| | |
| | | @Override |
| | | public synchronized CommandResponse sendCommand(CrnCommand command) { |
| | | this.crnProtocol.setLastCommandTime(System.currentTimeMillis()); |
| | | return zyCrnConnectThread.sendCommand(command); |
| | | return zyCrnConnectDriver.sendCommand(command); |
| | | } |
| | | } |
| | |
| | | Vue.component('watch-crn-card', { |
| | | template: ` |
| | | Vue.component("watch-crn-card", { |
| | | template: ` |
| | | <div> |
| | | <div style="display: flex;margin-bottom: 10px;"> |
| | | <div style="width: 100%;">堆垛机监控</div> |
| | | <div style="width: 100%;text-align: right;display: flex;"><el-input size="mini" v-model="searchCrnNo" placeholder="请输入堆垛机号"></el-input><el-button @click="getCrnStateInfo" size="mini">查询</el-button></div> |
| | | </div> |
| | | <div style="margin-bottom: 10px;"> |
| | | <div style="margin-bottom: 5px;"> |
| | | <el-button @click="openControl" size="mini">控制中心</el-button> |
| | | </div> |
| | | <div v-if="showControl" style="display: flex;justify-content: space-between;flex-wrap: wrap;"> |
| | | <div style="margin-bottom: 10px;width: 33%;"><el-input size="mini" v-model="controlParam.crnNo" placeholder="堆垛机号"></el-input></div> |
| | | <div style="margin-bottom: 10px;width: 33%;"><el-input size="mini" v-model="controlParam.sourceLocNo" placeholder="源点"></el-input></div> |
| | | <div style="margin-bottom: 10px;width: 33%;"><el-input size="mini" v-model="controlParam.targetLocNo" placeholder="目标点"></el-input></div> |
| | | <div style="margin-bottom: 10px;"><el-button @click="controlCommandTransport()" size="mini">取放货</el-button></div> |
| | | <div style="margin-bottom: 10px;"><el-button @click="controlCommandMove()" size="mini">移动</el-button></div> |
| | | <div style="margin-bottom: 10px;"><el-button @click="controlCommandTaskComplete()" size="mini">任务完成</el-button></div> |
| | | </div> |
| | | </div> |
| | | <el-collapse v-model="activeNames"> |
| | | <el-collapse-item v-for="(item) in crnList" :name="item.crnNo"> |
| | |
| | | </el-collapse> |
| | | </div> |
| | | `, |
| | | props: ['param'], |
| | | data() { |
| | | return { |
| | | crnList: [], |
| | | activeNames: '', |
| | | searchCrnNo: '' |
| | | props: ["param"], |
| | | data() { |
| | | return { |
| | | crnList: [], |
| | | activeNames: "", |
| | | searchCrnNo: "", |
| | | showControl: true, |
| | | controlParam: { |
| | | crnNo: "", |
| | | sourceLocNo: "", |
| | | targetLocNo: "", |
| | | }, |
| | | }; |
| | | }, |
| | | created() { |
| | | setInterval(() => { |
| | | this.getCrnStateInfo(); |
| | | }, 1000); |
| | | }, |
| | | watch: { |
| | | param: { |
| | | handler(newVal, oldVal) { |
| | | if (newVal.crnNo != 0) { |
| | | this.activeNames = newVal.crnNo; |
| | | } |
| | | }, |
| | | deep: true, // 深度监听嵌套属性 |
| | | immediate: true, // 立即触发一次(可选) |
| | | }, |
| | | created() { |
| | | setInterval(() => { |
| | | this.getCrnStateInfo() |
| | | },1000) |
| | | }, |
| | | watch: { |
| | | param: { |
| | | handler(newVal, oldVal) { |
| | | if(newVal.crnNo != 0) { |
| | | this.activeNames = newVal.crnNo |
| | | } |
| | | }, |
| | | deep: true, // 深度监听嵌套属性 |
| | | immediate: true // 立即触发一次(可选) |
| | | } |
| | | }, |
| | | methods: { |
| | | getCrnStateInfo() { |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/crn/table/crn/state", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | method: "post", |
| | | success: (res) => { |
| | | // 堆垛机信息表获取 |
| | | if (res.code == 200) { |
| | | let list = res.data; |
| | | |
| | | if (that.searchCrnNo == '') { |
| | | that.crnList = list; |
| | | }else { |
| | | let tmp = [] |
| | | list.forEach((item) => { |
| | | if(item.crnNo == that.searchCrnNo) { |
| | | tmp.push(item) |
| | | } |
| | | }) |
| | | that.crnList = tmp; |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | methods: { |
| | | getCrnStateInfo() { |
| | | let that = this; |
| | | $.ajax({ |
| | | url: baseUrl + "/crn/table/crn/state", |
| | | headers: { |
| | | token: localStorage.getItem("token"), |
| | | }, |
| | | } |
| | | }); |
| | | method: "post", |
| | | success: (res) => { |
| | | // 堆垛机信息表获取 |
| | | if (res.code == 200) { |
| | | let list = res.data; |
| | | |
| | | if (that.searchCrnNo == "") { |
| | | that.crnList = list; |
| | | } else { |
| | | let tmp = []; |
| | | list.forEach((item) => { |
| | | if (item.crnNo == that.searchCrnNo) { |
| | | tmp.push(item); |
| | | } |
| | | }); |
| | | that.crnList = tmp; |
| | | } |
| | | } |
| | | }, |
| | | }); |
| | | }, |
| | | openControl() { |
| | | this.showControl = !this.showControl; |
| | | }, |
| | | controlCommandTransport() { |
| | | let that = this; |
| | | //取放货 |
| | | $.ajax({ |
| | | url: baseUrl + "/crn/command/take", |
| | | headers: { |
| | | token: localStorage.getItem("token"), |
| | | }, |
| | | contentType: "application/json", |
| | | method: "post", |
| | | data: JSON.stringify(that.controlParam), |
| | | success: (res) => { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: "success", |
| | | }); |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: "warning", |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | }, |
| | | controlCommandMove() { |
| | | let that = this; |
| | | $.ajax({ |
| | | url: baseUrl + "/crn/command/move", |
| | | headers: { |
| | | token: localStorage.getItem("token"), |
| | | }, |
| | | contentType: "application/json", |
| | | method: "post", |
| | | data: JSON.stringify(that.controlParam), |
| | | success: (res) => { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: "success", |
| | | }); |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: "warning", |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | }, |
| | | controlCommandTaskComplete() { |
| | | let that = this; |
| | | $.ajax({ |
| | | url: baseUrl + "/crn/command/taskComplete", |
| | | headers: { |
| | | token: localStorage.getItem("token"), |
| | | }, |
| | | contentType: "application/json", |
| | | method: "post", |
| | | data: JSON.stringify(that.controlParam), |
| | | success: (res) => { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: "success", |
| | | }); |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: "warning", |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | }, |
| | | }, |
| | | }); |