From f7ca18ed5b63ae2336b8e29678194455503234b8 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期二, 20 十二月 2022 13:26:23 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/SteController.java | 70 ++++++++++++++++++++++++++++++++--- 1 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/SteController.java b/src/main/java/com/zy/asrs/controller/SteController.java index 209e18d..a3a34ad 100644 --- a/src/main/java/com/zy/asrs/controller/SteController.java +++ b/src/main/java/com/zy/asrs/controller/SteController.java @@ -7,10 +7,11 @@ import com.core.common.R; import com.core.exception.CoolException; import com.zy.asrs.domain.enums.CrnStatusType; +import com.zy.asrs.domain.param.SteModeParam; import com.zy.asrs.domain.param.SteOperatorParam; +import com.zy.asrs.domain.vo.SteDataVo; import com.zy.asrs.domain.vo.SteMsgTableVo; import com.zy.asrs.domain.vo.SteStateTableVo; -import com.zy.asrs.domain.vo.SteDataVo; import com.zy.asrs.entity.BasSte; import com.zy.asrs.entity.WrkMast; import com.zy.asrs.service.BasSteService; @@ -25,6 +26,7 @@ import com.zy.core.model.command.SteCommand; import com.zy.core.model.protocol.SteProtocol; import com.zy.core.properties.SlaveProperties; +import com.zy.core.properties.SystemProperties; import com.zy.core.thread.SteThread; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -69,7 +71,8 @@ if (steProtocol == null) { continue; } - vo.setTaskNo(steProtocol.getTaskNo()); // 浠诲姟鍙� + vo.setTaskNo(steProtocol.getTaskNo().intValue()); // 浠诲姟鍙� + vo.setStatusVal(steProtocol.getMode().intValue()); // 鍦ㄧ嚎鐘舵�� vo.setStatusType(steProtocol.mode == 0 ? "绂荤嚎" : "鍦ㄧ嚎"); // 妯″紡鐘舵�� if (!Cools.isEmpty(steProtocol.getStatus())) { vo.setStatus(steProtocol.getStatusType().desc); // 鐘舵�� @@ -95,6 +98,15 @@ if (!Cools.isEmpty(steProtocol.getTrack())) { vo.setTrack(steProtocol.getTrack()==0?"鉁�":"脳"); } + if (!Cools.isEmpty(steProtocol.getChargeStatus())) { + vo.setChargeStatus(steProtocol.getChargeStatus()==1?"鉁�":"脳"); + } + if (!Cools.isEmpty(steProtocol.getAlarm())) { + vo.setAlarm1(String.valueOf(steProtocol.getAlarm())); + } + if (!Cools.isEmpty(steProtocol.getAlarm0())) { + vo.setAlarm2(String.valueOf(steProtocol.getAlarm0())); + } } return R.ok().add(list); } @@ -119,7 +131,7 @@ continue; } - vo.setWorkNo(steProtocol.getTaskNo()); // 浠诲姟鍙� + vo.setWorkNo(steProtocol.getTaskNo().intValue()); // 浠诲姟鍙� if (steProtocol.getTaskNo() > 0) { WrkMast wrkMast = wrkMastService.selectById(steProtocol.getTaskNo()); if (wrkMast != null) { @@ -183,7 +195,7 @@ // 鑾峰彇绌挎杞︿俊鎭� SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, vo.getSteNo()); SteProtocol steProtocol = steThread.getSteProtocol(); - if (steProtocol != null) { + if (steProtocol == null) { throw new CoolException(vo.getSteNo() + "鍙风┛姊溅涓嶅湪绾匡紝鏃犳硶淇濆瓨"); } if (!Cools.isEmpty(vo.getRow(), vo.getBay(), vo.getLev())) { @@ -191,6 +203,16 @@ throw new CoolException("鏈嶅姟鍣ㄩ敊璇�"); } } + SteCommand steCommand = new SteCommand(); + steCommand.setTaskNo(vo.getWorkNo()); + if (MessageQueue.offer(SlaveType.Ste, vo.getSteNo(), new Task(2, steCommand))) { + } else { + throw new CoolException("鍛戒护涓嬪彂澶辫触"); + } + basSte.setRow(vo.getRow()); + basSte.setBay(vo.getBay()); + basSte.setLev(vo.getLev()); + basSte.setPakMk(vo.getPakMk()); basSte.setWrkNo(vo.getWorkNo()); basSte.setCrnNo(vo.getCrnNo()); @@ -205,6 +227,42 @@ /****************************************************************/ /************************** 鎵嬪姩鎿嶄綔 ******************************/ /****************************************************************/ + + @PostMapping("/mode/switch") + @ManagerAuth + public R crnDemo(SteModeParam param) throws InterruptedException { + if (Cools.isEmpty(param.getSteNo())){ + return R.error(); + } + if (Cools.isEmpty(param.getPassword())){ + return R.error("璇疯緭鍏ュ彛浠�"); + } + if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){ + return R.error("鍙d护閿欒"); + } + Thread.sleep(200L); + for (SteSlave steSlave : slaveProperties.getSte()) { + if (steSlave.getId().equals(param.getSteNo())) { + // 鑾峰彇绌挎杞︿俊鎭� + SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steSlave.getId()); + SteProtocol steProtocol = steThread.getSteProtocol(); + if (steProtocol == null) { continue; } + SteCommand steCommand = new SteCommand(); + steCommand.setSteNo(param.getSteNo()); // 绌挎杞︾紪鍙� + if (steProtocol.getMode() == 0) { + steCommand.setControlMode((short) 1); + } else { + steCommand.setControlMode((short) 0); + } + if (MessageQueue.offer(SlaveType.Ste, param.getSteNo(), new Task(2, steCommand))) { + return R.ok(); + } else { + throw new CoolException("鍛戒护涓嬪彂澶辫触"); + } + } + } + return R.ok(); + } @ManagerAuth(memo = "鎵嬪姩鎿嶄綔") @PostMapping("/operator/ste") @@ -229,9 +287,9 @@ steCommand.setSteNo(ste.getId()); // 绌挎杞︾紪鍙� if (param.getSteTaskMode() == 16) { steCommand.setComplete(true); - } else if (param.getSteTaskMode() == 17) { + } else if (param.getSteTaskMode() == 99) { steCommand.setControlMode((short) 1); - } else if (param.getSteTaskMode() == 18) { + } else if (param.getSteTaskMode() == 100) { steCommand.setControlMode((short) 0); } else { if (steTaskModeType == null) { -- Gitblit v1.9.1