From 13f3721a678782cfa042acca5208644e8f32dcfb Mon Sep 17 00:00:00 2001 From: pang.jiabao <pang_jiabao@163.com> Date: 星期一, 14 四月 2025 16:55:26 +0800 Subject: [PATCH] 界面翻译为俄语 --- src/main/java/com/zy/asrs/controller/CrnController.java | 463 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 405 insertions(+), 58 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/CrnController.java b/src/main/java/com/zy/asrs/controller/CrnController.java index dd1872d..2a60511 100644 --- a/src/main/java/com/zy/asrs/controller/CrnController.java +++ b/src/main/java/com/zy/asrs/controller/CrnController.java @@ -1,42 +1,98 @@ package com.zy.asrs.controller; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.annotations.ManagerAuth; +import com.core.common.Cools; import com.core.common.R; +import com.core.exception.CoolException; import com.zy.asrs.domain.enums.CrnStatusType; +import com.zy.asrs.domain.param.CrnDemoParam; import com.zy.asrs.domain.param.CrnOperatorParam; 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.BasCrnError; +import com.zy.asrs.entity.BasCrnp; +import com.zy.asrs.entity.LocMast; +import com.zy.asrs.entity.WrkMast; +import com.zy.asrs.mapper.BasCrnErrorMapper; +import com.zy.asrs.service.BasCrnpService; +import com.zy.asrs.service.LocMastService; +import com.zy.asrs.service.WrkMastService; +import com.zy.asrs.service.impl.MainServiceImpl; +import com.zy.asrs.utils.VersionUtils; +import com.zy.core.CrnThread; +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.CrnTaskModeType; +import com.zy.core.enums.SlaveType; +import com.zy.core.model.CrnSlave; +import com.zy.core.model.Task; +import com.zy.core.model.command.CrnCommand; +import com.zy.core.model.protocol.CrnProtocol; +import com.zy.core.properties.SlaveProperties; +import com.zy.core.properties.SystemProperties; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; -import java.util.Date; +import java.util.HashMap; import java.util.List; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; /** * 鍫嗗灈鏈烘帴鍙� * Created by vincent on 2020-06-01 */ +@Slf4j @RestController @RequestMapping("/crn") public class CrnController { - public static AtomicInteger integer = new AtomicInteger(); + @Autowired + private SlaveProperties slaveProperties; + @Autowired + private WrkMastService wrkMastService; + @Autowired + private BasCrnErrorMapper basCrnErrorMapper; + @Autowired + private BasCrnpService basCrnpService; + @Autowired + private MainServiceImpl mainService; + @Autowired + private LocMastService locMastService; + @ManagerAuth(memo = "杩涜涓殑鍛戒护") @PostMapping("/command/ongoing") public R ongoingCommand(){ List<CommandLogVo> list = new ArrayList<>(); - for (int i=1;i<=4;i++){ + for (CrnSlave crn : slaveProperties.getCrn()) { CommandLogVo vo = new CommandLogVo(); - vo.setCrnNo(String.valueOf(i)); - vo.setStatus(1); - vo.setCommand(UUID.randomUUID().toString()); + vo.setCrnNo(crn.getId()); // 鍫嗗灈鏈哄彿 + vo.setStatus(0); // 鐘舵�� list.add(vo); + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + if (crnThread == null) { + continue; + } + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + vo.setStatus(1); // 鐘舵�� + Task task = MessageQueue.peek(SlaveType.Crn, crn.getId()); + if (task != null) { + vo.setCommand(JSON.toJSONString((CrnCommand)task.getData())); + } } return R.ok().add(list); } @@ -45,16 +101,37 @@ @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, "姝e父", "鏈夌墿", "99", "3", "涓綅", "18233", "422", "0", "1204", "鍏抽棴", "0"); - if (integer.get()%5 == 0) { - vo.setWorkNo("0000"); - } else { - vo.setWorkNo("9998"); - } + List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); + for (BasCrnp basCrnp : crnps) { + // 琛ㄦ牸琛� + CrnStateTableVo vo = new CrnStateTableVo(); + vo.setCrnNo(basCrnp.getCrnNo()); // 鍫嗗灈鏈哄彿 list.add(vo); + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo()); + if (crnThread == null) { + continue; + } + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + vo.setWorkNo(crnProtocol.getTaskNo()); // 浠诲姟鍙� + vo.setStatusType(crnProtocol.modeType.desc); // 妯″紡鐘舵�� + vo.setStatus(crnProtocol.getStatusType().desc); // 鐘舵�� + 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.setWarnCode(String.valueOf(crnProtocol.getAlarm())); + if (crnProtocol.getAlarm() > 0) { + BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); + vo.setAlarm(crnError==null?"鏈煡寮傚父":crnError.getErrName()); + } } - integer.getAndIncrement(); return R.ok().add(list); } @@ -62,34 +139,96 @@ @ManagerAuth(memo = "鍫嗗灈鏈烘暟鎹〃") public R crnMsgTable(){ List<CrnMsgTableVo> list = new ArrayList<>(); - for (int i=1;i<=4;i++){ + List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); + for (BasCrnp basCrnp : crnps) { + // 琛ㄦ牸琛� CrnMsgTableVo vo = new CrnMsgTableVo(); - vo.setCrnNo(String.valueOf(i)); - vo.setCommand("28283E23132D23"); - vo.setError(""); - vo.setLocNo("0601812"); - vo.setOrigin("0"); - vo.setSourceLocNo(""); - vo.setSourceStaNo("0"); - vo.setStaNo("2112"); - vo.setStatus("绌洪棽"); - if (integer.get()%5 == 0) { - vo.setWorkNo("0000"); - } else { - vo.setWorkNo("9998"); - } + vo.setCrnNo(basCrnp.getCrnNo()); // 鍫嗗灈鏈哄彿 list.add(vo); + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo()); + if (crnThread == null) { + continue; + } + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + + vo.setWorkNo(crnProtocol.getTaskNo()); // 浠诲姟鍙� + if (crnProtocol.getTaskNo()>0) { + WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); + if (wrkMast != null) { + vo.setStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc()); // 妯″紡鐘舵�� + vo.setSourceStaNo(wrkMast.getSourceStaNo$()); // 婧愮珯 + vo.setStaNo(wrkMast.getStaNo$()); // 鐩爣绔� + vo.setSourceLocNo(wrkMast.getSourceLocNo()); // 婧愬簱浣� + vo.setLocNo(wrkMast.getLocNo()); // 鐩爣搴撲綅 + } + } else { + vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc()); // 妯″紡鐘舵�� + } + vo.setXspeed(crnProtocol.getXSpeed()); // 璧拌閫熷害锛坢/min) + vo.setYspeed(crnProtocol.getYSpeed()); // 鍗囬檷閫熷害锛坢/min) + vo.setZspeed(crnProtocol.getZSpeed()); // 鍙夌墮閫熷害锛坢/min) + vo.setXdistance(crnProtocol.getXDistance()); // 璧拌璺濈(Km) + vo.setYdistance(crnProtocol.getYDistance()); // 鍗囬檷璺濈(Km) + vo.setXduration(crnProtocol.getXDuration()); // 璧拌鏃堕暱(H) + vo.setYduration(crnProtocol.getYDuration()); // 鍗囬檷鏃堕暱(H) } - integer.getAndIncrement(); return R.ok().add(list); } @PostMapping("/output/site") @ManagerAuth(memo = "鍫嗗灈鏈烘姤鏂囨棩蹇楄緭鍑�") public R crnOutput(){ - String str = "\n" +new Date().toLocaleString() + "銆�2020-5-29 13:14:22銆戞壂鎻弍lcA 鐩爣绔�--273283723728327636432343234323422732837237283276364323432343234227328372372832763643234323432342"; - return R.ok().add(str); + StringBuilder str = new StringBuilder(); + String s; + int i = 0; + while((s = OutputQueue.CRN.poll()) != null && i <=10) { + str.append("\n").append(s); + i++; + } + return R.ok().add(str.toString()); } + + + @GetMapping("/demo/status") + public R demoStatus(){ + List<Map<String, Object>> res = new ArrayList<>(); + for (CrnSlave crnSlave : slaveProperties.getCrn()) { + Map<String, Object> map = new HashMap<>(); + map.put("crnNo", crnSlave.getId()); + map.put("demo", crnSlave.getDemo()); + res.add(map); + } + return R.ok().add(res); + } + + + @PostMapping("/demo/switch") + @ManagerAuth(memo = "鍫嗗灈鏈烘紨绀�") + public R crnDemo(CrnDemoParam param) throws InterruptedException { + if (Cools.isEmpty(param.getCrnId())){ + 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 (CrnSlave crnSlave : slaveProperties.getCrn()) { + if (crnSlave.getId().equals(param.getCrnId())) { + crnSlave.setDemo(param.getOpt()); + } + } +// mainService.crnDemoOfLocMove(param.getCrnId()); + return R.ok(); + } + + /****************************************************************/ /************************** 鎵嬪姩鎿嶄綔 ******************************/ @@ -98,61 +237,269 @@ @ManagerAuth(memo = "鍏ュ簱") @PostMapping("/operator/put") public R crnPut(CrnOperatorParam param){ - return R.ok("鍏ュ簱鎴愬姛"); + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.PAKIN); // 浠诲姟妯″紡 + command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓 + command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪 + command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰 + command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺� + command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); } @ManagerAuth(memo = "鍑哄簱") @PostMapping("/operator/take") public R crnTake(CrnOperatorParam param){ - return R.ok("鍑哄簱鎴愬姛"); + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.PAKOUT); // 浠诲姟妯″紡 + command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓 + command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪 + command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰 + command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺� + command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); } @ManagerAuth(memo = "搴撲綅杞Щ") @PostMapping("/operator/stockMove") public R crnStockMove(CrnOperatorParam param){ - return R.ok("搴撲綅杞Щ鎴愬姛"); + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡 + command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓 + command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪 + command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰 + command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺� + command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞� + LocMast sourceLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getSourcePosX()) + .eq("bay1", command.getSourcePosY()).eq("lev1", command.getSourcePosZ())); + LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getDestinationPosX()) + .eq("bay1", command.getDestinationPosY()).eq("lev1", command.getDestinationPosZ())); + VersionUtils.locMoveCheckLocType(sourceLoc, loc); + return crnControl(command)?R.ok():R.error(); } @ManagerAuth(memo = "绔欏埌绔�") @PostMapping("/operator/siteMove") public R crnSiteMove(CrnOperatorParam param){ - return R.ok("绔欏埌绔欐垚鍔�"); - } - - @ManagerAuth(memo = "鍧愭爣绉诲姩") - @PostMapping("/operator/coorMove") - public R crnCoorMove(CrnOperatorParam param){ - return R.ok("鍧愭爣绉诲姩鎴愬姛"); + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡 + command.setSourcePosX(param.getSourceStaNo()); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰 + command.setDestinationPosX(param.getStaNo()); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); } @ManagerAuth(memo = "鍥炲師鐐�") @PostMapping("/operator/bacOrigin") public R crnBacOrigin(CrnOperatorParam param){ - return R.ok("鍥炲師鐐规垚鍔�"); + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡 + command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 + command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); } + + @ManagerAuth(memo = "鍙嶅師鐐�") + @PostMapping("/operator/reverseOrigin") + public R reverseOrigin(CrnOperatorParam param){ + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡 + command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 + command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 34); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 5); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); + } + +// @ManagerAuth(memo = "鍧愭爣绉诲姩") +// @PostMapping("/operator/coorMove") +// public R crnCoorMove(CrnOperatorParam param){ +// CrnCommand command = new CrnCommand(); +// command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� +// command.setTaskNo((short) 0); // 宸ヤ綔鍙� +// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� +// command.setTaskMode(CrnTaskModeType.OFFSET_MOVE); // 浠诲姟妯″紡 +// command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓 +// command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪 +// command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰 +// command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺� +// command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒� +// command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞� +// staNoProcess(param, command); +// return crnControl(command)?R.ok():R.error(); +// } @ManagerAuth(memo = "浠诲姟瀹屾垚") @PostMapping("/operator/taskComplete") public R crnTaskComplete(CrnOperatorParam param){ - return R.ok("浠诲姟瀹屾垚"); + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 1); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.NONE); // 浠诲姟妯″紡 + command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 + command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); } - @ManagerAuth(memo = "鏆傚仠") - @PostMapping("/operator/pause") - public R crnPause(CrnOperatorParam param){ - return R.ok("鏆傚仠鎴愬姛"); - } - - @ManagerAuth(memo = "鍚姩") - @PostMapping("/operator/boot") - public R crnBoot(CrnOperatorParam param){ - return R.ok("鍚姩鎴愬姛"); - } +// @ManagerAuth(memo = "鏆傚仠") +// @PostMapping("/operator/pause") +// public R crnPause(CrnOperatorParam param){ +// return R.ok("鏆傚仠鎴愬姛"); +// } +// +// @ManagerAuth(memo = "鍚姩") +// @PostMapping("/operator/boot") +// public R crnBoot(CrnOperatorParam param){ +// return R.ok("鍚姩鎴愬姛"); +// } @ManagerAuth(memo = "娓呴櫎鍛戒护") @PostMapping("/operator/clearCommand") public R crnClearCommand(CrnOperatorParam param){ - return R.ok("娓呴櫎鍛戒护鎴愬姛"); + if (param.getCrnNo() == null) { + throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�"); + } + CrnCommand command = new CrnCommand(); + command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo((short) 0); // 宸ヤ綔鍙� + command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + command.setTaskMode(CrnTaskModeType.NONE); // 浠诲姟妯″紡 + command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 + command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + return crnControl(command)?R.ok():R.error(); } + @ManagerAuth(memo = "鎵嬪姩澶嶄綅") + @PostMapping("/operator/handleReset") + public R handleReset(CrnOperatorParam param) throws Exception { + if (param.getCrnNo() == null) { + throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�"); + } + // 鑾峰彇鍫嗗灈鏈虹紦瀛� + for (CrnSlave crn : slaveProperties.getCrn()) { + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + if (param.getCrnNo().equals(crn.getId())) { + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + if (crnThread == null) { + throw new CoolException("鍫嗗灈鏈轰笉鍦ㄧ嚎"); + } + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + throw new CoolException("鍫嗗灈鏈轰笉鍦ㄧ嚎"); + } + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(crn.getId()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskMode(CrnTaskModeType.CLEAR); + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setCommand((short) 0); // 浠诲姟瀹屾垚纭浣� + // 寤舵椂鍙戦�� + Thread.sleep(1000L); + if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand))) { + return R.ok(); + } else { + throw new CoolException("鍛戒护涓嬪彂澶辫触"); + } + + + } + } + + return R.error(); + } + + private boolean crnControl(CrnCommand command){ + if (command.getCrnNo() == null) { + throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�"); + } + for (CrnSlave crn : slaveProperties.getCrn()) { + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + if (command.getCrnNo().equals(crn.getId())) { + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + if (crnThread == null) { + throw new CoolException("鍫嗗灈鏈轰笉鍦ㄧ嚎"); + } + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + throw new CoolException("鍫嗗灈鏈轰笉鍦ㄧ嚎"); + } + // 绌洪棽鍒ゆ柇 +// if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.IDLE) && crnProtocol.getTaskNo() == 0) { + if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, command))) { + return true; + } else { + throw new CoolException("鍛戒护涓嬪彂澶辫触"); + } +// } else { +// throw new CoolException("鍫嗗灈鏈轰笉鍦ㄧ┖闂茬姸鎬�"); +// } + } + } + return false; + } + + private void staNoProcess(CrnOperatorParam param, CrnCommand command){ + if (param.getSourceStaNo()!=null) { + if (param.getSourceStaNo() == 5) { + command.setSourcePosX((short) 2); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰 + } else if (param.getSourceStaNo() == 6) { + command.setSourcePosX((short) 1); // 婧愬簱浣嶆帓 + command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + command.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰 + } + } + if (param.getStaNo()!=null) { + if (param.getStaNo() == 5) { + command.setDestinationPosX((short) 2); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞� + } else if (param.getStaNo() == 6) { + command.setDestinationPosX((short) 1); // 鐩爣搴撲綅鎺� + command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞� + } + } + } + + } -- Gitblit v1.9.1