From ccc39836716ba323c946cddc78a62049731ebb46 Mon Sep 17 00:00:00 2001 From: dubin <bindu_bean@163.com> Date: 星期二, 07 十月 2025 08:43:33 +0800 Subject: [PATCH] 联调 --- src/main/java/com/zy/asrs/controller/CrnController.java | 110 +++++++++++++++++++++++++++++------------------------- 1 files changed, 59 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/CrnController.java b/src/main/java/com/zy/asrs/controller/CrnController.java index abfdd84..dd1ec9d 100644 --- a/src/main/java/com/zy/asrs/controller/CrnController.java +++ b/src/main/java/com/zy/asrs/controller/CrnController.java @@ -21,7 +21,6 @@ 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; @@ -35,7 +34,6 @@ import com.zy.core.model.protocol.CrnProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.properties.SystemProperties; -import com.zy.core.thread.RgvThread; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -73,7 +71,7 @@ @ManagerAuth(memo = "杩涜涓殑鍛戒护") @PostMapping("/command/ongoing") - public R ongoingCommand(){ + public R ongoingCommand() { List<CommandLogVo> list = new ArrayList<>(); for (CrnSlave crn : slaveProperties.getCrn()) { CommandLogVo vo = new CommandLogVo(); @@ -92,7 +90,7 @@ vo.setStatus(1); // 鐘舵�� Task task = MessageQueue.peek(SlaveType.Crn, crn.getId()); if (task != null) { - vo.setCommand(JSON.toJSONString((CrnCommand)task.getData())); + vo.setCommand(JSON.toJSONString((CrnCommand) task.getData())); } } return R.ok().add(list); @@ -100,7 +98,7 @@ @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) { @@ -120,20 +118,22 @@ vo.setWorkNo(crnProtocol.getTaskNo()); // 浠诲姟鍙� vo.setStatusType(crnProtocol.modeType.desc); // 妯″紡鐘舵�� vo.setStatus(crnProtocol.getStatusType().desc); // 鐘舵�� - vo.setLoading(crnProtocol.getLoaded()==1?"鏈夌墿":"鏃犵墿"); // 鏈夌墿 + vo.setLoading(crnProtocol.getLoaded() == 1 ? "鏈夌墿" : "鏃犵墿"); // 鏈夌墿 + vo.setLoadTwoing(crnProtocol.getLoadedTwo() == 1 ? "鏈夌墿" : "鏃犵墿"); // 鏈夌墿 + vo.setBay(crnProtocol.getBay()); // 鍒� vo.setLev(crnProtocol.getLevel()); // 灞� vo.setForkOffset(crnProtocol.getForkPosType().desc); // 璐у弶浣嶇疆 vo.setLiftPos(crnProtocol.getLiftPosType().desc); - vo.setWalkPos(crnProtocol.getWalkPos()==1?"涓嶅湪瀹氫綅":"鍦ㄥ畾浣�"); - if(crnProtocol.getAlarm() == 10){ + vo.setWalkPos(crnProtocol.getWalkPos() == 1 ? "涓嶅湪瀹氫綅" : "鍦ㄥ畾浣�"); + if (crnProtocol.getAlarm() == 10) { crnProtocol.setAlarm((short) 0); } vo.setWarnCode(String.valueOf(crnProtocol.getAlarm())); if (crnProtocol.getAlarm() > 0) { BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); - vo.setAlarm(crnError==null?"鏈煡寮傚父":crnError.getErrName()); + vo.setAlarm(crnError == null ? "鏈煡寮傚父" : crnError.getErrName()); } } return R.ok().add(list); @@ -141,7 +141,7 @@ @PostMapping("/table/crn/msg") @ManagerAuth(memo = "鍫嗗灈鏈烘暟鎹〃") - public R crnMsgTable(){ + public R crnMsgTable() { List<CrnMsgTableVo> list = new ArrayList<>(); List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); for (BasCrnp basCrnp : crnps) { @@ -160,7 +160,7 @@ } vo.setWorkNo(crnProtocol.getTaskNo()); // 浠诲姟鍙� - if (crnProtocol.getTaskNo()>0) { + if (crnProtocol.getTaskNo() > 0) { WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); if (wrkMast != null) { vo.setStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc()); // 妯″紡鐘舵�� @@ -170,8 +170,21 @@ vo.setLocNo(wrkMast.getLocNo()); // 鐩爣搴撲綅 } } else { - vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc()); // 妯″紡鐘舵�� + vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO.getDesc() : CrnStatusType.MACHINE_UN_AUTO.getDesc()); // 妯″紡鐘舵�� } + + if (crnProtocol.getTaskNoTwo() > 0) { + WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNoTwo()); + if (wrkMast != null) { + vo.setSourceStaNo2(wrkMast.getSourceStaNo$()); // 婧愮珯 + vo.setStaNo2(wrkMast.getStaNo$()); // 鐩爣绔� + vo.setSourceLocNo2(wrkMast.getSourceLocNo()); // 婧愬簱浣� + vo.setLocNo2(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) @@ -185,11 +198,11 @@ @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++; } @@ -198,7 +211,7 @@ @GetMapping("/demo/status") - public R demoStatus(){ + public R demoStatus() { List<Map<String, Object>> res = new ArrayList<>(); for (CrnSlave crnSlave : slaveProperties.getCrn()) { Map<String, Object> map = new HashMap<>(); @@ -213,13 +226,13 @@ @PostMapping("/demo/switch") @ManagerAuth(memo = "鍫嗗灈鏈烘紨绀�") public R crnDemo(CrnDemoParam param) throws InterruptedException { - if (Cools.isEmpty(param.getCrnId())){ + if (Cools.isEmpty(param.getCrnId())) { return R.error(); } - if (Cools.isEmpty(param.getPassword())){ + if (Cools.isEmpty(param.getPassword())) { return R.error("璇疯緭鍏ュ彛浠�"); } - if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){ + if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)) { return R.error("鍙d护閿欒"); } Thread.sleep(200L); @@ -231,7 +244,6 @@ // mainService.crnDemoOfLocMove(param.getCrnId()); return R.ok(); } - /****************************************************************/ @@ -275,10 +287,9 @@ // command.setTraySize(locSts); // return crnControl(command)?R.ok():R.error(); // } - @ManagerAuth(memo = "搴撲綅杞Щ") @PostMapping("/operator/stockMove") - public R crnStockMove(CrnOperatorParam param){ + public R crnStockMove(CrnOperatorParam param) { CrnCommand command = new CrnCommand(); command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� command.setTaskNo((short) 0); // 宸ヤ綔鍙� @@ -294,17 +305,17 @@ .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())); - if (sourceLoc.getLocType1() != loc.getLocType1()){ + if (sourceLoc.getLocType1() != loc.getLocType1()) { return R.error("搴撲綅绫诲瀷涓嶄竴鑷�"); } command.setTraySize(loc.getLocType1() == 2); // VersionUtils.locMoveCheckLocType(sourceLoc, loc); - return crnControl(command)?R.ok():R.error(); + return crnControl(command) ? R.ok() : R.error(); } @ManagerAuth(memo = "绔欏埌绔�") @PostMapping("/operator/siteMove") - public R crnSiteMove(CrnOperatorParam param){ + public R crnSiteMove(CrnOperatorParam param) { CrnCommand command = new CrnCommand(); command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� command.setTaskNo((short) 0); // 宸ヤ綔鍙� @@ -316,12 +327,12 @@ command.setDestinationPosX(param.getStaNo()); // 鐩爣搴撲綅鎺� command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞� - return crnControl(command)?R.ok():R.error(); + return crnControl(command) ? R.ok() : R.error(); } @ManagerAuth(memo = "鍥炲師鐐�") @PostMapping("/operator/bacOrigin") - public R crnBacOrigin(CrnOperatorParam param){ + public R crnBacOrigin(CrnOperatorParam param) { CrnCommand command = new CrnCommand(); command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� command.setTaskNo((short) 0); // 宸ヤ綔鍙� @@ -333,12 +344,12 @@ command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� - return crnControl(command)?R.ok():R.error(); + return crnControl(command) ? R.ok() : R.error(); } @ManagerAuth(memo = "鍙嶅師鐐�") @PostMapping("/operator/reverseOrigin") - public R reverseOrigin(CrnOperatorParam param){ + public R reverseOrigin(CrnOperatorParam param) { CrnCommand command = new CrnCommand(); command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� command.setTaskNo((short) 0); // 宸ヤ綔鍙� @@ -350,7 +361,7 @@ command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� command.setDestinationPosY((short) 34); // 鐩爣搴撲綅鍒� command.setDestinationPosZ((short) 5); // 鐩爣搴撲綅灞� - return crnControl(command)?R.ok():R.error(); + return crnControl(command) ? R.ok() : R.error(); } // @ManagerAuth(memo = "鍧愭爣绉诲姩") @@ -373,8 +384,9 @@ @ManagerAuth(memo = "浠诲姟瀹屾垚") @PostMapping("/operator/taskComplete") - public R crnTaskComplete(CrnOperatorParam param){ + public R crnTaskComplete(CrnOperatorParam param) { CrnCommand command = new CrnCommand(); + command.setPltType(param.getC()); command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� command.setTaskNo((short) 0); // 宸ヤ綔鍙� command.setAckFinish((short) 1); // 浠诲姟瀹屾垚纭浣� @@ -385,9 +397,8 @@ command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� - return crnControl(command)?R.ok():R.error(); + return crnControl(command) ? R.ok() : R.error(); } - // @ManagerAuth(memo = "鏆傚仠") @@ -404,7 +415,7 @@ @ManagerAuth(memo = "娓呴櫎鍛戒护") @PostMapping("/operator/clearCommand") - public R crnClearCommand(CrnOperatorParam param){ + public R crnClearCommand(CrnOperatorParam param) { if (param.getCrnNo() == null) { throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�"); } @@ -419,7 +430,7 @@ command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� - return crnControl(command)?R.ok():R.error(); + return crnControl(command) ? R.ok() : R.error(); } @ManagerAuth(memo = "鎵嬪姩澶嶄綅") @@ -460,7 +471,7 @@ return R.error(); } - private boolean crnControl(CrnCommand command){ + private boolean crnControl(CrnCommand command) { if (command.getCrnNo() == null) { throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�"); } @@ -476,22 +487,19 @@ 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("鍫嗗灈鏈轰笉鍦ㄧ┖闂茬姸鎬�"); -// } + if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, command))) { + return true; + } else { + throw new CoolException("鍛戒护涓嬪彂澶辫触"); + } + } } return false; } - private void staNoProcess(CrnOperatorParam param, CrnCommand command){ - if (param.getSourceStaNo()!=null) { + private void staNoProcess(CrnOperatorParam param, CrnCommand command) { + if (param.getSourceStaNo() != null) { if (param.getSourceStaNo() == 5) { command.setSourcePosX((short) 2); // 婧愬簱浣嶆帓 command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 @@ -502,7 +510,7 @@ command.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰 } } - if (param.getStaNo()!=null) { + if (param.getStaNo() != null) { if (param.getStaNo() == 5) { command.setDestinationPosX((short) 2); // 鐩爣搴撲綅鎺� command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� @@ -515,16 +523,16 @@ } } - private boolean isLocSts(String row,String bay,String lev){ + private boolean isLocSts(String row, String bay, String lev) { int rowInt = Integer.parseInt(row); int bayInt = Integer.parseInt(bay); int levInt = Integer.parseInt(lev); - String loc = String.format("%2d",rowInt)+String.format("%3d",bayInt)+String.format("%2d",levInt); + String loc = String.format("%2d", rowInt) + String.format("%3d", bayInt) + String.format("%2d", levInt); LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", loc)); - if (Cools.isEmpty(locMast)){ + if (Cools.isEmpty(locMast)) { return false; } - if (locMast.getLocType1() == 2){ + if (locMast.getLocType1() == 2) { return true; } return false; -- Gitblit v1.9.1