From 1d624dfdb040825ffecba6c792c480be662b2dbc Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期四, 10 四月 2025 17:39:56 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 8 src/main/java/com/zy/core/model/command/LiftAssignCommand.java | 2 src/main/java/com/zy/asrs/controller/ForkLiftController.java | 666 +++--- src/main/java/com/zy/core/model/protocol/LiftProtocol.java | 304 ++ src/main/java/com/zy/asrs/task/WrkMastScheduler.java | 7 src/main/java/com/zy/asrs/domain/vo/LiftMsgTableVo.java | 8 src/main/java/com/zy/asrs/utils/Utils.java | 1 src/main/java/com/zy/core/action/LiftAction.java | 207 + src/main/java/com/zy/core/action/ShuttleAction.java | 10 src/main/webapp/views/index.html | 2 src/main/java/com/zy/core/MainProcess.java | 15 src/main/java/com/zy/common/utils/NavigateMapData.java | 4 src/main/java/com/zy/common/service/CommonService.java | 26 src/main/java/com/zy/core/thread/impl/NyLiftThread.java | 649 ++++++ src/main/java/com/zy/core/enums/LiftProtocolStatusType.java | 43 src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java | 138 - src/main/java/com/zy/core/thread/LiftThread.java | 67 src/main/java/com/zy/asrs/controller/OpenController.java | 2 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 2878 ++++++++++++++++++++++---- src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java | 4 src/main/java/com/zy/core/action/ForkLiftAction.java | 174 src/main/resources/mapper/WrkMastMapper.xml | 2 src/main/java/com/zy/core/model/LiftSlave.java | 16 src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java | 36 src/main/java/com/zy/common/CodeBuilder.java | 4 src/main/java/com/zy/core/ServerBootstrap.java | 23 src/main/webapp/views/lift.html | 32 src/main/java/com/zy/core/properties/SlaveProperties.java | 2 src/main/java/com/zy/core/enums/WrkStsType.java | 30 src/main/java/com/zy/core/model/command/LiftCommand.java | 74 src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java | 3 src/main/java/com/zy/core/enums/LiftCommandModeType.java | 48 src/main/java/com/zy/asrs/domain/param/CreateMoveTaskParam.java | 4 src/main/java/com/zy/common/utils/LiftUtils.java | 255 ++ src/main/java/com/zy/core/enums/RedisKeyType.java | 2 src/main/resources/application.yml | 65 src/main/java/com/zy/asrs/controller/LiftController.java | 391 +++ 37 files changed, 5,010 insertions(+), 1,192 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ForkLiftController.java b/src/main/java/com/zy/asrs/controller/ForkLiftController.java index 844e50a..a0004e6 100644 --- a/src/main/java/com/zy/asrs/controller/ForkLiftController.java +++ b/src/main/java/com/zy/asrs/controller/ForkLiftController.java @@ -1,333 +1,333 @@ -package com.zy.asrs.controller; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.core.annotations.ManagerAuth; -import com.core.common.BaseRes; -import com.core.common.Cools; -import com.core.common.R; -import com.core.exception.CoolException; -import com.zy.asrs.domain.param.LiftOperatorParam; -import com.zy.asrs.domain.vo.*; -import com.zy.asrs.entity.BasLift; -import com.zy.asrs.service.BasLiftService; -import com.zy.common.service.CommonService; -import com.zy.common.utils.RedisUtil; -import com.zy.core.action.ForkLiftAction; -import com.zy.core.cache.OutputQueue; -import com.zy.core.cache.SlaveConnection; -import com.zy.core.enums.ForkLiftProtocolStatusType; -import com.zy.core.enums.ForkLiftTaskModeType; -import com.zy.core.enums.RedisKeyType; -import com.zy.core.enums.SlaveType; -import com.zy.core.model.ForkLiftSlave; -import com.zy.core.model.command.*; -import com.zy.core.model.protocol.ForkLiftProtocol; -import com.zy.core.model.protocol.ForkLiftStaProtocol; -import com.zy.core.properties.SlaveProperties; -import com.zy.core.thread.ForkLiftThread; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; - -/** - * 璐у弶鎻愬崌鏈烘帴鍙� - */ -@Slf4j -@RestController -@RequestMapping("/forkLift") -public class ForkLiftController { - - @Autowired - private CommonService commonService; - @Autowired - private SlaveProperties slaveProperties; - @Autowired - private BasLiftService basLiftService; - @Autowired - private RedisUtil redisUtil; - @Autowired - private ForkLiftAction forkLiftAction; - - @PostMapping("/table/lift/state") - @ManagerAuth(memo = "鎻愬崌鏈轰俊鎭〃") - public R liftStateTable(){ - ArrayList<JSONObject> list = new ArrayList<>(); - for (ForkLiftSlave slave : slaveProperties.getForkLift()) { - // 琛ㄦ牸琛� - JSONObject baseObj = new JSONObject(); - baseObj.put("shuttleNo", slave.getId()); - list.add(baseObj); - // 鑾峰彇鎻愬崌鏈轰俊鎭� - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - JSONObject data = JSON.parseObject(JSON.toJSONString(forkLiftProtocol)); - List<ForkLiftStaProtocol> forkLiftStaProtocols = forkLiftThread.getForkLiftStaProtocols(); - data.put("forkLiftStaProtocols", forkLiftStaProtocols); - baseObj.putAll(data); - } - return R.ok().add(list); - } - - @PostMapping("/table/lift/msg") - @ManagerAuth(memo = "鎻愬崌鏈烘暟鎹〃") - public R liftMsgTable(){ - List<LiftMsgTableVo> list = new ArrayList<>(); - for (ForkLiftSlave slave : slaveProperties.getForkLift()) { - // 琛ㄦ牸琛� - LiftMsgTableVo vo = new LiftMsgTableVo(); - vo.setLiftNo(slave.getId()); // 鎻愬崌鏈哄彿 - list.add(vo); - // 鑾峰彇鎻愬崌鏈轰俊鎭� - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - - vo.setWorkNo(forkLiftProtocol.getTaskNo());//浠诲姟鍙� - vo.setPakMk(forkLiftProtocol.getPakMk()?"Y" : "N"); // 浣滀笟鏍囪 - vo.setForkLiftStaProtocols(forkLiftThread.getForkLiftStaProtocols()); - } - return R.ok().add(list); - } - - @PostMapping("/output/lift") - @ManagerAuth - public R liftOutput(){ - StringBuilder str = new StringBuilder(); - String s; - int i = 0; - while((s = OutputQueue.LIFT.poll()) != null && i <=10) { - str.append("\n").append(s); - i++; - } - return R.ok().add(str.toString()); - } - - @GetMapping("/detl/{liftNo}") - public R liftDetl(@PathVariable("liftNo") Integer liftNo){ - LiftDataVo vo = new LiftDataVo(); - for (ForkLiftSlave liftSlave : slaveProperties.getForkLift()) { - if (liftNo.equals(liftSlave.getId())) { - vo.setLiftNo(liftSlave.getId()); - BasLift basLift = basLiftService.selectById(liftSlave.getId()); - if (!Cools.isEmpty(basLift)) { - vo.setWorkNo(basLift.getWrkNo()); - vo.setPakMk(basLift.getPakMk()); - } - break; - } - } - return R.ok().add(vo); - } - - @GetMapping("/sensor/detl/{liftNo}") - public R liftSensorDetl(@PathVariable("liftNo") Integer liftNo){ - LiftSensorDataVo vo = new LiftSensorDataVo(); - for (ForkLiftSlave liftSlave : slaveProperties.getForkLift()) { - if (liftNo.equals(liftSlave.getId())) { - vo.setLiftNo(liftSlave.getId()); - // 鑾峰彇鎻愬崌鏈轰俊鎭� - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSlave.getId()); - if (forkLiftThread == null) { - return R.error("璁惧涓嶅湪绾�"); - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return R.error("璁惧涓嶅湪绾�"); - } - - break; - } - } - return R.ok().add(vo); - } - - @PostMapping("/detl/update") - @ManagerAuth(memo = "淇敼鏁版嵁") - public R liftUpdate(@RequestParam Integer liftNo, - @RequestParam Short workNo) { - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - return R.error("plc宸叉帀绾�"); - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return R.error("plc宸叉帀绾�"); - } - if (workNo != null) { - forkLiftThread.setSyncTaskNo(workNo.intValue()); - } - return R.ok(); - } - - @RequestMapping(value = "/command/query") - public R liftCommandQuery(@RequestParam("wrkNo") Integer wrkNo) { - Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); - if (o == null) { - return R.error(); - } - LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); - return R.ok().add(redisCommand); - } - - //鍥為��鍛戒护 - @RequestMapping(value = "/command/rollback") - public R liftCommandRollback(@RequestParam("wrkNo") Integer wrkNo - , @RequestParam("commandStep") Integer commandStep) { - Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); - if (o == null) { - return R.error(); - } - LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); - redisCommand.setCommandStep(commandStep); - redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo, JSON.toJSONString(redisCommand)); - return R.ok(); - } - - //鍛戒护瀹屾垚鐘舵�佸垏鎹� - @RequestMapping(value = "/command/completeSwitch") - public R liftCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo - , @RequestParam("commandStep") Integer commandStep - , @RequestParam("complete") Integer complete) { - Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); - if (o == null) { - return R.error(); - } - LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); - LiftAssignCommand assignCommand = redisCommand.getAssignCommand(); - List<ForkLiftCommand> commands = assignCommand.getCommands(); - ForkLiftCommand command = commands.get(commandStep); - command.setComplete(complete != 0); - redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo, JSON.toJSONString(redisCommand)); - return R.ok(); - } - - //閲嶅惎浠诲姟(鍛戒护) - @RequestMapping(value = "/command/restart") - public R liftCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo) { - Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); - if (o == null) { - return R.error(); - } - LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); - Short liftNo = redisCommand.getLiftNo(); - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo.intValue()); - if (forkLiftThread == null) { - return R.error(); - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return R.error(); - } - if (!forkLiftThread.isIdle()) { - return R.error(); - } - //鎻愬崌鏈哄浜庣┖闂茬姸鎬侊紝杩涜浠诲姟鐨勬仮澶� - forkLiftThread.setSyncTaskNo(redisCommand.getWrkNo().intValue());//灏嗘彁鍗囨満绾跨▼鍒嗛厤浠诲姟鍙� - return R.ok(); - } - - //鍒犻櫎浠诲姟(鍛戒护) - @RequestMapping(value = "/command/del") - public R liftCommandDel(@RequestParam("wrkNo") Integer wrkNo) { - Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); - if (o == null) { - return R.error(); - } - redisUtil.del(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); - return R.ok(); - } - - /****************************************************************/ - /************************** 鎵嬪姩鎿嶄綔 ******************************/ - /****************************************************************/ - - @ManagerAuth(memo = "鎵嬪姩鎿嶄綔") - @PostMapping("/operator/lift") - public R liftOperator(LiftOperatorParam param){ - if (Cools.isEmpty(param.getLiftNo())) { - return R.parse(BaseRes.PARAM); - } - - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, param.getLiftNo()); - if (forkLiftThread == null) { - throw new CoolException("鎻愬崌鏈轰笉鍦ㄧ嚎"); - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - throw new CoolException("鎻愬崌鏈轰笉鍦ㄧ嚎"); - } - - if (param.getLiftTaskMode() == 1) { - //灏忚溅鎹㈠眰 - int workNo = commonService.getWorkNo(99);//鑾峰彇浠诲姟鍙� - - Integer startSta = param.getSourceStaNo(); - Integer targetSta = param.getStaNo(); - - //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommand = forkLiftThread.getShuttleSwitchCommand(workNo, startSta, targetSta); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommand); - - //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 - LiftAssignCommand assignCommand = new LiftAssignCommand(); - assignCommand.setCommands(commands); - assignCommand.setLiftNo(forkLiftProtocol.getLiftNo().shortValue()); - assignCommand.setTaskNo((short) workNo); - assignCommand.setAuto(false);//鎵嬪姩妯″紡 - assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue()); - - forkLiftAction.assignWork(forkLiftProtocol.getLiftNo(), assignCommand); - return R.ok(); - } else if (param.getLiftTaskMode() == 2) { - //绉诲姩鎵樼洏 - int workNo = commonService.getWorkNo(99);//鑾峰彇浠诲姟鍙� - - Integer startSta = param.getSourceStaNo(); - Integer targetSta = param.getStaNo(); - - //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommand = forkLiftThread.getPickAndPutCommand(workNo, startSta, targetSta); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommand); - - //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 - LiftAssignCommand assignCommand = new LiftAssignCommand(); - assignCommand.setCommands(commands); - assignCommand.setLiftNo(forkLiftProtocol.getLiftNo().shortValue()); - assignCommand.setTaskNo((short) workNo); - assignCommand.setAuto(false);//鎵嬪姩妯″紡 - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); - - forkLiftAction.assignWork(forkLiftProtocol.getLiftNo(), assignCommand); - return R.ok(); - } else if (param.getLiftTaskMode() == 3) { - //浠诲姟纭 - forkLiftThread.reset(); - return R.ok(); - } else if (param.getLiftTaskMode() == 0) { - //鎻愬崌鏈哄浣� - forkLiftThread.setSyncTaskNo(0); - forkLiftThread.setProtocolStatus(ForkLiftProtocolStatusType.IDLE); - return R.ok(); - } else { - throw new CoolException("鏈煡鍛戒护"); - } - } - -} +//package com.zy.asrs.controller; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.core.annotations.ManagerAuth; +//import com.core.common.BaseRes; +//import com.core.common.Cools; +//import com.core.common.R; +//import com.core.exception.CoolException; +//import com.zy.asrs.domain.param.LiftOperatorParam; +//import com.zy.asrs.domain.vo.*; +//import com.zy.asrs.entity.BasLift; +//import com.zy.asrs.service.BasLiftService; +//import com.zy.common.service.CommonService; +//import com.zy.common.utils.RedisUtil; +//import com.zy.core.action.ForkLiftAction; +//import com.zy.core.cache.OutputQueue; +//import com.zy.core.cache.SlaveConnection; +//import com.zy.core.enums.ForkLiftProtocolStatusType; +//import com.zy.core.enums.ForkLiftTaskModeType; +//import com.zy.core.enums.RedisKeyType; +//import com.zy.core.enums.SlaveType; +//import com.zy.core.model.ForkLiftSlave; +//import com.zy.core.model.command.*; +//import com.zy.core.model.protocol.ForkLiftProtocol; +//import com.zy.core.model.protocol.ForkLiftStaProtocol; +//import com.zy.core.properties.SlaveProperties; +//import com.zy.core.thread.ForkLiftThread; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.*; +// +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * 璐у弶鎻愬崌鏈烘帴鍙� +// */ +//@Slf4j +//@RestController +//@RequestMapping("/forkLift") +//public class ForkLiftController { +// +// @Autowired +// private CommonService commonService; +// @Autowired +// private SlaveProperties slaveProperties; +// @Autowired +// private BasLiftService basLiftService; +// @Autowired +// private RedisUtil redisUtil; +// @Autowired +// private ForkLiftAction forkLiftAction; +// +// @PostMapping("/table/lift/state") +// @ManagerAuth(memo = "鎻愬崌鏈轰俊鎭〃") +// public R liftStateTable(){ +// ArrayList<JSONObject> list = new ArrayList<>(); +// for (ForkLiftSlave slave : slaveProperties.getForkLift()) { +// // 琛ㄦ牸琛� +// JSONObject baseObj = new JSONObject(); +// baseObj.put("shuttleNo", slave.getId()); +// list.add(baseObj); +// // 鑾峰彇鎻愬崌鏈轰俊鎭� +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// JSONObject data = JSON.parseObject(JSON.toJSONString(forkLiftProtocol)); +// List<ForkLiftStaProtocol> forkLiftStaProtocols = forkLiftThread.getForkLiftStaProtocols(); +// data.put("forkLiftStaProtocols", forkLiftStaProtocols); +// baseObj.putAll(data); +// } +// return R.ok().add(list); +// } +// +// @PostMapping("/table/lift/msg") +// @ManagerAuth(memo = "鎻愬崌鏈烘暟鎹〃") +// public R liftMsgTable(){ +// List<LiftMsgTableVo> list = new ArrayList<>(); +// for (ForkLiftSlave slave : slaveProperties.getForkLift()) { +// // 琛ㄦ牸琛� +// LiftMsgTableVo vo = new LiftMsgTableVo(); +// vo.setLiftNo(slave.getId()); // 鎻愬崌鏈哄彿 +// list.add(vo); +// // 鑾峰彇鎻愬崌鏈轰俊鎭� +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// +// vo.setWorkNo(forkLiftProtocol.getTaskNo());//浠诲姟鍙� +// vo.setPakMk(forkLiftProtocol.getPakMk()?"Y" : "N"); // 浣滀笟鏍囪 +// vo.setForkLiftStaProtocols(forkLiftThread.getForkLiftStaProtocols()); +// } +// return R.ok().add(list); +// } +// +// @PostMapping("/output/lift") +// @ManagerAuth +// public R liftOutput(){ +// StringBuilder str = new StringBuilder(); +// String s; +// int i = 0; +// while((s = OutputQueue.LIFT.poll()) != null && i <=10) { +// str.append("\n").append(s); +// i++; +// } +// return R.ok().add(str.toString()); +// } +// +// @GetMapping("/detl/{liftNo}") +// public R liftDetl(@PathVariable("liftNo") Integer liftNo){ +// LiftDataVo vo = new LiftDataVo(); +// for (ForkLiftSlave liftSlave : slaveProperties.getForkLift()) { +// if (liftNo.equals(liftSlave.getId())) { +// vo.setLiftNo(liftSlave.getId()); +// BasLift basLift = basLiftService.selectById(liftSlave.getId()); +// if (!Cools.isEmpty(basLift)) { +// vo.setWorkNo(basLift.getWrkNo()); +// vo.setPakMk(basLift.getPakMk()); +// } +// break; +// } +// } +// return R.ok().add(vo); +// } +// +// @GetMapping("/sensor/detl/{liftNo}") +// public R liftSensorDetl(@PathVariable("liftNo") Integer liftNo){ +// LiftSensorDataVo vo = new LiftSensorDataVo(); +// for (ForkLiftSlave liftSlave : slaveProperties.getForkLift()) { +// if (liftNo.equals(liftSlave.getId())) { +// vo.setLiftNo(liftSlave.getId()); +// // 鑾峰彇鎻愬崌鏈轰俊鎭� +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSlave.getId()); +// if (forkLiftThread == null) { +// return R.error("璁惧涓嶅湪绾�"); +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return R.error("璁惧涓嶅湪绾�"); +// } +// +// break; +// } +// } +// return R.ok().add(vo); +// } +// +// @PostMapping("/detl/update") +// @ManagerAuth(memo = "淇敼鏁版嵁") +// public R liftUpdate(@RequestParam Integer liftNo, +// @RequestParam Short workNo) { +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// return R.error("plc宸叉帀绾�"); +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return R.error("plc宸叉帀绾�"); +// } +// if (workNo != null) { +// forkLiftThread.setSyncTaskNo(workNo.intValue()); +// } +// return R.ok(); +// } +// +// @RequestMapping(value = "/command/query") +// public R liftCommandQuery(@RequestParam("wrkNo") Integer wrkNo) { +// Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// return R.ok().add(redisCommand); +// } +// +// //鍥為��鍛戒护 +// @RequestMapping(value = "/command/rollback") +// public R liftCommandRollback(@RequestParam("wrkNo") Integer wrkNo +// , @RequestParam("commandStep") Integer commandStep) { +// Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// redisCommand.setCommandStep(commandStep); +// redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo, JSON.toJSONString(redisCommand)); +// return R.ok(); +// } +// +// //鍛戒护瀹屾垚鐘舵�佸垏鎹� +// @RequestMapping(value = "/command/completeSwitch") +// public R liftCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo +// , @RequestParam("commandStep") Integer commandStep +// , @RequestParam("complete") Integer complete) { +// Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// LiftAssignCommand assignCommand = redisCommand.getAssignCommand(); +// List<ForkLiftCommand> commands = assignCommand.getCommands(); +// ForkLiftCommand command = commands.get(commandStep); +// command.setComplete(complete != 0); +// redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo, JSON.toJSONString(redisCommand)); +// return R.ok(); +// } +// +// //閲嶅惎浠诲姟(鍛戒护) +// @RequestMapping(value = "/command/restart") +// public R liftCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo) { +// Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// Short liftNo = redisCommand.getLiftNo(); +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo.intValue()); +// if (forkLiftThread == null) { +// return R.error(); +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return R.error(); +// } +// if (!forkLiftThread.isIdle()) { +// return R.error(); +// } +// //鎻愬崌鏈哄浜庣┖闂茬姸鎬侊紝杩涜浠诲姟鐨勬仮澶� +// forkLiftThread.setSyncTaskNo(redisCommand.getWrkNo().intValue());//灏嗘彁鍗囨満绾跨▼鍒嗛厤浠诲姟鍙� +// return R.ok(); +// } +// +// //鍒犻櫎浠诲姟(鍛戒护) +// @RequestMapping(value = "/command/del") +// public R liftCommandDel(@RequestParam("wrkNo") Integer wrkNo) { +// Object o = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// redisUtil.del(RedisKeyType.FORK_LIFT_WORK_FLAG.key + wrkNo); +// return R.ok(); +// } +// +// /****************************************************************/ +// /************************** 鎵嬪姩鎿嶄綔 ******************************/ +// /****************************************************************/ +// +// @ManagerAuth(memo = "鎵嬪姩鎿嶄綔") +// @PostMapping("/operator/lift") +// public R liftOperator(LiftOperatorParam param){ +// if (Cools.isEmpty(param.getLiftNo())) { +// return R.parse(BaseRes.PARAM); +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, param.getLiftNo()); +// if (forkLiftThread == null) { +// throw new CoolException("鎻愬崌鏈轰笉鍦ㄧ嚎"); +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// throw new CoolException("鎻愬崌鏈轰笉鍦ㄧ嚎"); +// } +// +// if (param.getLiftTaskMode() == 1) { +// //灏忚溅鎹㈠眰 +// int workNo = commonService.getWorkNo(99);//鑾峰彇浠诲姟鍙� +// +// Integer startSta = param.getSourceStaNo(); +// Integer targetSta = param.getStaNo(); +// +// //鑾峰彇鎻愬崌鏈哄懡浠� +// List<ForkLiftCommand> liftCommand = forkLiftThread.getShuttleSwitchCommand(workNo, startSta, targetSta); +// ArrayList<ForkLiftCommand> commands = new ArrayList<>(); +// commands.addAll(liftCommand); +// +// //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 +// LiftAssignCommand assignCommand = new LiftAssignCommand(); +// assignCommand.setCommands(commands); +// assignCommand.setLiftNo(forkLiftProtocol.getLiftNo().shortValue()); +// assignCommand.setTaskNo((short) workNo); +// assignCommand.setAuto(false);//鎵嬪姩妯″紡 +// assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue()); +// +// forkLiftAction.assignWork(forkLiftProtocol.getLiftNo(), assignCommand); +// return R.ok(); +// } else if (param.getLiftTaskMode() == 2) { +// //绉诲姩鎵樼洏 +// int workNo = commonService.getWorkNo(99);//鑾峰彇浠诲姟鍙� +// +// Integer startSta = param.getSourceStaNo(); +// Integer targetSta = param.getStaNo(); +// +// //鑾峰彇鎻愬崌鏈哄懡浠� +// List<ForkLiftCommand> liftCommand = forkLiftThread.getPickAndPutCommand(workNo, startSta, targetSta); +// ArrayList<ForkLiftCommand> commands = new ArrayList<>(); +// commands.addAll(liftCommand); +// +// //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 +// LiftAssignCommand assignCommand = new LiftAssignCommand(); +// assignCommand.setCommands(commands); +// assignCommand.setLiftNo(forkLiftProtocol.getLiftNo().shortValue()); +// assignCommand.setTaskNo((short) workNo); +// assignCommand.setAuto(false);//鎵嬪姩妯″紡 +// assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); +// +// forkLiftAction.assignWork(forkLiftProtocol.getLiftNo(), assignCommand); +// return R.ok(); +// } else if (param.getLiftTaskMode() == 3) { +// //浠诲姟纭 +// forkLiftThread.reset(); +// return R.ok(); +// } else if (param.getLiftTaskMode() == 0) { +// //鎻愬崌鏈哄浣� +// forkLiftThread.setSyncTaskNo(0); +// forkLiftThread.setProtocolStatus(ForkLiftProtocolStatusType.IDLE); +// return R.ok(); +// } else { +// throw new CoolException("鏈煡鍛戒护"); +// } +// } +// +//} diff --git a/src/main/java/com/zy/asrs/controller/LiftController.java b/src/main/java/com/zy/asrs/controller/LiftController.java new file mode 100644 index 0000000..baec8b3 --- /dev/null +++ b/src/main/java/com/zy/asrs/controller/LiftController.java @@ -0,0 +1,391 @@ +package com.zy.asrs.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.core.annotations.ManagerAuth; +import com.core.common.BaseRes; +import com.core.common.Cools; +import com.core.common.R; +import com.core.exception.CoolException; +import com.zy.asrs.domain.param.LiftOperatorParam; +import com.zy.asrs.domain.vo.LiftDataVo; +import com.zy.asrs.domain.vo.LiftMsgTableVo; +import com.zy.asrs.domain.vo.LiftSensorDataVo; +import com.zy.asrs.entity.BasLift; +import com.zy.asrs.service.BasLiftService; +import com.zy.common.service.CommonService; +import com.zy.common.utils.RedisUtil; +import com.zy.core.action.LiftAction; +import com.zy.core.cache.OutputQueue; +import com.zy.core.cache.SlaveConnection; +import com.zy.core.enums.*; +import com.zy.core.model.LiftSlave; +import com.zy.core.model.command.LiftAssignCommand; +import com.zy.core.model.command.LiftCommand; +import com.zy.core.model.protocol.LiftProtocol; +import com.zy.core.model.protocol.LiftStaProtocol; +import com.zy.core.properties.SlaveProperties; +import com.zy.core.thread.LiftThread; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * 鎻愬崌鏈烘帴鍙� + */ +@Slf4j +@RestController +@RequestMapping("/lift") +public class LiftController { + + @Autowired + private SlaveProperties slaveProperties; + @Autowired + private BasLiftService basLiftService; + @Autowired + private CommonService commonService; + @Autowired + private RedisUtil redisUtil; + @Autowired + private LiftAction liftAction; + + @PostMapping("/table/lift/state") + @ManagerAuth(memo = "鎻愬崌鏈轰俊鎭〃") + public R liftStateTable(){ + ArrayList<JSONObject> list = new ArrayList<>(); + for (LiftSlave slave : slaveProperties.getLift()) { + // 琛ㄦ牸琛� + JSONObject baseObj = new JSONObject(); + baseObj.put("shuttleNo", slave.getId()); + list.add(baseObj); + // 鑾峰彇鎻愬崌鏈轰俊鎭� + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + continue; + } + JSONObject data = JSON.parseObject(JSON.toJSONString(liftProtocol)); + List<LiftStaProtocol> liftStaProtocols = liftThread.getLiftStaProtocols(); + data.put("liftStaProtocols", liftStaProtocols); + baseObj.putAll(data); + } + return R.ok().add(list); + } + + @PostMapping("/table/lift/msg") + @ManagerAuth(memo = "鎻愬崌鏈烘暟鎹〃") + public R liftMsgTable(){ + List<LiftMsgTableVo> list = new ArrayList<>(); + for (LiftSlave slave : slaveProperties.getLift()) { + // 琛ㄦ牸琛� + LiftMsgTableVo vo = new LiftMsgTableVo(); + vo.setLiftNo(slave.getId()); // 鎻愬崌鏈哄彿 + list.add(vo); + // 鑾峰彇鎻愬崌鏈轰俊鎭� + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + continue; + } + + vo.setWorkNo(liftProtocol.getTaskNo());//浠诲姟鍙� + vo.setPakMk(liftProtocol.getPakMk()?"Y" : "N"); // 浣滀笟鏍囪 + vo.setLiftStaProtocols(liftThread.getLiftStaProtocols()); + vo.setCompleteTaskNo(Integer.parseInt(liftProtocol.getCompleteTaskNo())); + vo.setLev(liftProtocol.getLev()); + } + return R.ok().add(list); + } + + @PostMapping("/output/lift") + @ManagerAuth + public R liftOutput(){ + StringBuilder str = new StringBuilder(); + String s; + int i = 0; + while((s = OutputQueue.LIFT.poll()) != null && i <=10) { + str.append("\n").append(s); + i++; + } + return R.ok().add(str.toString()); + } + + @GetMapping("/detl/{liftNo}") + public R liftDetl(@PathVariable("liftNo") Integer liftNo){ + LiftDataVo vo = new LiftDataVo(); + for (LiftSlave liftSlave : slaveProperties.getLift()) { + if (liftNo.equals(liftSlave.getId())) { + vo.setLiftNo(liftSlave.getId()); + BasLift basLift = basLiftService.selectById(liftSlave.getId()); + if (!Cools.isEmpty(basLift)) { + vo.setWorkNo(basLift.getWrkNo()); + vo.setPakMk(basLift.getPakMk()); + } + break; + } + } + return R.ok().add(vo); + } + + @GetMapping("/sensor/detl/{liftNo}") + public R liftSensorDetl(@PathVariable("liftNo") Integer liftNo){ + LiftSensorDataVo vo = new LiftSensorDataVo(); + for (LiftSlave liftSlave : slaveProperties.getLift()) { + if (liftNo.equals(liftSlave.getId())) { + vo.setLiftNo(liftSlave.getId()); + // 鑾峰彇鎻愬崌鏈轰俊鎭� + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); + if (liftThread == null) { + return R.error("璁惧涓嶅湪绾�"); + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return R.error("璁惧涓嶅湪绾�"); + } + + break; + } + } + return R.ok().add(vo); + } + + /****************************************************************/ + /************************** 鎵嬪姩鎿嶄綔 ******************************/ + /****************************************************************/ + + @ManagerAuth(memo = "鎵嬪姩鎿嶄綔") + @PostMapping("/operator/lift") + public R liftOperator(LiftOperatorParam param){ + if (Cools.isEmpty(param.getLiftNo())) { + return R.parse(BaseRes.PARAM); + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, param.getLiftNo()); + if (liftThread == null) { + throw new CoolException("鎻愬崌鏈轰笉鍦ㄧ嚎"); + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + throw new CoolException("鎻愬崌鏈轰笉鍦ㄧ嚎"); + } + + if (param.getLiftTaskMode() == 1) { + + return R.ok(); + } else if (param.getLiftTaskMode() == 5) { + //鎵樼洏鍏� + int workNo = commonService.getWorkNo(8);//鑾峰彇浠诲姟鍙� + + Integer startSta = param.getSourceStaNo(); + Integer targetSta = param.getStaNo(); + + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommand = liftThread.getPalletInCommand(workNo, startSta, targetSta); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.addAll(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(liftProtocol.getLiftNo().shortValue()); + assignCommand.setTaskNo((short) workNo); + assignCommand.setAuto(false);//鎵嬪姩妯″紡 + assignCommand.setTaskMode(LiftCommandModeType.PALLET_IN.id.shortValue()); + + liftAction.assignWork(liftProtocol.getLiftNo(), assignCommand); + return R.ok(); + } else if (param.getLiftTaskMode() == 6) { + //鎵樼洏鍏� + int workNo = commonService.getWorkNo(8);//鑾峰彇浠诲姟鍙� + + Integer startSta = param.getSourceStaNo(); + Integer targetSta = param.getStaNo(); + + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommand = liftThread.getPalletOutCommand(workNo, startSta, targetSta); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.addAll(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(liftProtocol.getLiftNo().shortValue()); + assignCommand.setTaskNo((short) workNo); + assignCommand.setAuto(false);//鎵嬪姩妯″紡 + assignCommand.setTaskMode(LiftCommandModeType.PALLET_OUT.id.shortValue()); + + liftAction.assignWork(liftProtocol.getLiftNo(), assignCommand); + return R.ok(); + } else if (param.getLiftTaskMode() == 7) { + //绉诲姩 + int workNo = commonService.getWorkNo(8);//鑾峰彇浠诲姟鍙� + + Integer startSta = param.getSourceStaNo(); + Integer targetSta = param.getStaNo(); + + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommand = liftThread.getMoveCommand(workNo, startSta, targetSta, LiftCommandModeType.MOVE); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.addAll(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(liftProtocol.getLiftNo().shortValue()); + assignCommand.setTaskNo((short) workNo); + assignCommand.setAuto(false);//鎵嬪姩妯″紡 + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); + + liftAction.assignWork(liftProtocol.getLiftNo(), assignCommand); + return R.ok(); + } else if (param.getLiftTaskMode() == 8) { + //绉诲姩 + int workNo = commonService.getWorkNo(8);//鑾峰彇浠诲姟鍙� + + Integer startSta = param.getSourceStaNo(); + Integer targetSta = param.getStaNo(); + + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommand = liftThread.getMoveWithShuttleCommand(workNo, startSta, targetSta, LiftCommandModeType.MOVE); + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.addAll(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(liftProtocol.getLiftNo().shortValue()); + assignCommand.setTaskNo((short) workNo); + assignCommand.setAuto(false);//鎵嬪姩妯″紡 + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); + + liftAction.assignWork(liftProtocol.getLiftNo(), assignCommand); + return R.ok(); + } else if (param.getLiftTaskMode() == 3) { + //绛夊緟纭 + liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING); + return R.ok(); + } else if (param.getLiftTaskMode() == 0) { + //鎻愬崌鏈哄浣� + liftThread.setSyncTaskNo(0); + liftThread.setProtocolStatus(LiftProtocolStatusType.IDLE); + return R.ok(); + } else { + throw new CoolException("鏈煡鍛戒护"); + } + } + +// @PostMapping("/detl/update") +// @ManagerAuth(memo = "淇敼鏁版嵁") +// public R liftUpdate(@RequestParam Integer liftNo, +// @RequestParam Short workNo, +// @RequestParam String pakMk, +// @RequestParam Integer token) { +// LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); +// if (liftThread == null) { +// return R.error("plc宸叉帀绾�"); +// } +// LiftProtocol liftProtocol = liftThread.getLiftProtocol(); +// if (liftProtocol == null) { +// return R.error("plc宸叉帀绾�"); +// } +// if (workNo != null) { +// liftProtocol.setTaskNo(workNo); +// } +// if (pakMk != null) { +// liftProtocol.setPakMk(pakMk.equals("Y")); +// } +// if (token != null) { +// liftProtocol.setToken(token); +// } +// return R.ok(); +// } +// +// @RequestMapping(value = "/command/query") +// public R liftCommandQuery(@RequestParam("wrkNo") Integer wrkNo) { +// Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// return R.ok().add(redisCommand); +// } +// +// //鍥為��鍛戒护 +// @RequestMapping(value = "/command/rollback") +// public R liftCommandRollback(@RequestParam("wrkNo") Integer wrkNo +// , @RequestParam("commandStep") Integer commandStep) { +// Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// redisCommand.setCommandStep(commandStep); +// redisUtil.set(RedisKeyType.LIFT.key + wrkNo, JSON.toJSONString(redisCommand)); +// return R.ok(); +// } +// +// //鍛戒护瀹屾垚鐘舵�佸垏鎹� +// @RequestMapping(value = "/command/completeSwitch") +// public R liftCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo +// , @RequestParam("commandStep") Integer commandStep +// , @RequestParam("complete") Integer complete) { +// Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// LiftAssignCommand assignCommand = redisCommand.getAssignCommand(); +// List<NyLiftCommand> commands = assignCommand.getCommands(); +// NyLiftCommand command = commands.get(commandStep); +// command.setComplete(complete != 0); +// redisUtil.set(RedisKeyType.LIFT.key + wrkNo, JSON.toJSONString(redisCommand)); +// return R.ok(); +// } +// +// //閲嶅惎浠诲姟(鍛戒护) +// @RequestMapping(value = "/command/restart") +// public R liftCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo) { +// Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// LiftRedisCommand redisCommand = JSON.parseObject(o.toString(), LiftRedisCommand.class); +// Short liftNo = redisCommand.getLiftNo(); +// LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo.intValue()); +// if (liftThread == null) { +// return R.error(); +// } +// LiftProtocol liftProtocol = liftThread.getLiftProtocol(); +// if (liftProtocol == null) { +// return R.error(); +// } +// if (!liftProtocol.isIdle()) { +// return R.error(); +// } +// //鎻愬崌鏈哄浜庣┖闂茬姸鎬侊紝杩涜浠诲姟鐨勬仮澶� +// liftProtocol.setTaskNo(redisCommand.getWrkNo());//灏嗘彁鍗囨満绾跨▼鍒嗛厤浠诲姟鍙� +// liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);//宸ヤ綔鐘舵�� +// return R.ok(); +// } +// +// //鍒犻櫎浠诲姟(鍛戒护) +// @RequestMapping(value = "/command/del") +// public R liftCommandDel(@RequestParam("wrkNo") Integer wrkNo) { +// Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo); +// if (o == null) { +// return R.error(); +// } +// redisUtil.del(RedisKeyType.LIFT.key + wrkNo); +// return R.ok(); +// } + +} diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java index fed6c93..36213ba 100644 --- a/src/main/java/com/zy/asrs/controller/OpenController.java +++ b/src/main/java/com/zy/asrs/controller/OpenController.java @@ -56,7 +56,7 @@ if (param == null) { return R.error("鍙傛暟涓嶈兘涓虹┖"); } - boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(null, param.getLocNo(), param.getShuttleNo()); + boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(null, param.getSourceLocNo(), param.getLocNo(), param.getShuttleNo(), param.getFlag()); apiLogService.insert(new ApiLog( null , "灏忚溅绉诲姩浠诲姟" diff --git a/src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java b/src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java index 49505dd..1d52975 100644 --- a/src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java +++ b/src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java @@ -5,12 +5,15 @@ SHUTTLE_TRANSPORT("shuttle_transport", "灏忚溅閫佽揣涓�"), SHUTTLE_DELIVERY("shuttle_delivery", "灏忚溅鏀捐揣瀹屾垚"), SHUTTLE_MOVING("shuttle_moving", "灏忚溅绉诲姩涓�"), + SHUTTLE_MOVING_IN_LIFT("shuttle_moving_in_lift", "灏忚溅杩涘叆鎻愬崌鏈轰腑"), + SHUTTLE_MOVING_OUT_LIFT("shuttle_moving_out_lift", "灏忚溅杩佸嚭鎻愬崌鏈轰腑"), SHUTTLE_MOVE_COMPLETE("shuttle_move_complete", "灏忚溅绉诲姩瀹屾垚"), SHUTTLE_POWER_LOW("shuttle_power_low", "灏忚溅浣庣數閲�"), SHUTTLE_POWER_START("shuttle_power_start", "灏忚溅寮�濮嬪厖鐢�"), SHUTTLE_POWER_COMPLETE("shuttle_power_complete", "灏忚溅鍏呯數瀹屾垚"), SHUTTLE_ERROR("shuttle_error", "灏忚溅寮傚父"), FORK_LIFT_ERROR("fork_lift_error", "璐у弶鎻愬崌鏈哄紓甯�"), + LIFT_MOVE_SHUTTLE("lift_move_shuttle", "鎻愬崌鏈烘惉杩愬皬杞︿腑"), //浠诲姟 TASK_COMPLETE("task_complete", "浠诲姟瀹屾垚"), diff --git a/src/main/java/com/zy/asrs/domain/param/CreateMoveTaskParam.java b/src/main/java/com/zy/asrs/domain/param/CreateMoveTaskParam.java index 2a8070e..ac2fec0 100644 --- a/src/main/java/com/zy/asrs/domain/param/CreateMoveTaskParam.java +++ b/src/main/java/com/zy/asrs/domain/param/CreateMoveTaskParam.java @@ -7,6 +7,10 @@ private Integer shuttleNo; + private String sourceLocNo; + private String locNo; + private String flag; + } diff --git a/src/main/java/com/zy/asrs/domain/vo/LiftMsgTableVo.java b/src/main/java/com/zy/asrs/domain/vo/LiftMsgTableVo.java index a981a72..83dfef1 100644 --- a/src/main/java/com/zy/asrs/domain/vo/LiftMsgTableVo.java +++ b/src/main/java/com/zy/asrs/domain/vo/LiftMsgTableVo.java @@ -1,6 +1,6 @@ package com.zy.asrs.domain.vo; -import com.zy.core.model.protocol.ForkLiftStaProtocol; +import com.zy.core.model.protocol.LiftStaProtocol; import lombok.Data; import java.util.List; @@ -20,11 +20,15 @@ /** * 绔欑偣淇℃伅 */ - private List<ForkLiftStaProtocol> forkLiftStaProtocols; + private List<LiftStaProtocol> liftStaProtocols; /** * 绌挎杞﹀彿 */ private Integer shuttleNo; + private Integer completeTaskNo; + + private Integer lev; + } diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index 8e967d5..35e110a 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -12,7 +12,7 @@ import com.zy.common.service.CommonService; import com.zy.common.utils.*; import com.zy.core.News; -import com.zy.core.action.ForkLiftAction; +import com.zy.core.action.LiftAction; import com.zy.core.action.ShuttleAction; import com.zy.core.cache.SlaveConnection; import com.zy.core.dispatcher.ShuttleDispatchUtils; @@ -71,11 +71,13 @@ @Autowired private ShuttleAction shuttleAction; @Autowired - private ForkLiftAction forkLiftAction; - @Autowired private NotifyUtils notifyUtils; @Autowired private BasShuttleChargeService basShuttleChargeService; + @Autowired + private BasLiftOptService basLiftOptService; + @Autowired + private LiftAction liftAction; /** * 鍒濆鍖栧疄鏃跺湴鍥� @@ -430,6 +432,10 @@ //302.灏忚溅绉诲姩鑷崇珯鐐� ==> 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE.sts); shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT.sts) { + //304.灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT_COMPLETE.sts); + shuttleThread.setSyncTaskNo(0); } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT.sts) { //308.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { @@ -442,16 +448,39 @@ wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE.sts); shuttleThread.setSyncTaskNo(0); notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVE_COMPLETE);//瑙﹀彂閫氱煡 + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_TRANSPORT_LIFT.sts) { + //灏忚溅绉诲姩鑷崇珯鐐� ==> 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE_TRANSPORT_LIFT.sts); + shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_TRANSPORT_LIFT.sts) { + //灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT_COMPLETE_TRANSPORT_LIFT.sts); + shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT_TRANSPORT_LIFT.sts) { + //灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_COMPLETE_TRANSPORT_LIFT.sts); + shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SHUTTLE_TRANSPORT_LIFT.sts) { + //灏忚溅鏀捐揣涓� ==> 灏忚溅鏀捐揣瀹屾垚 + wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE_TRANSPORT_LIFT.sts); + shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_TRANSPORT_LIFT_OUT.sts) { + //灏忚溅绉诲姩鑷崇珯鐐� ==> 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE_TRANSPORT_LIFT_OUT.sts); + shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_TRANSPORT_LIFT_OUT.sts) { + //灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT_COMPLETE_TRANSPORT_LIFT_OUT.sts); + shuttleThread.setSyncTaskNo(0); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT_TRANSPORT_LIFT_OUT.sts) { + //灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 灏忚溅鏀捐揣瀹屾垚 + wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE_TRANSPORT_LIFT_OUT.sts); + shuttleThread.setSyncTaskNo(0); } else if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_WORKING.sts) { //204.灏忚溅鍏呯數涓� ==> 205.灏忚溅鍏呯數瀹屾垚 wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_COMPLETE.sts); shuttleThread.setSyncTaskNo(0); notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//瑙﹀彂閫氱煡 - } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_SHUTTLE_RUN.sts) { - //502.灏忚溅鎼繍涓� ==> 509.绉诲簱瀹屾垚 - wrkMast.setWrkSts(WrkStsType.COMPLETE_LOC_MOVE.sts); - shuttleThread.setSyncTaskNo(0); - notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_DELIVERY);//瑙﹀彂閫氱煡 } else { continue; } @@ -491,10 +520,20 @@ public synchronized void shuttleLocMoveExecute() { try { //鏌ヨ绉诲簱浠诲姟 - List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)); + List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts, WrkStsType.LOC_MOVE_SHUTTLE_TAKE.sts, WrkStsType.LOC_MOVE_SHUTTLE_PUT.sts)); for (WrkMast wrkMast : wrkMasts) { - boolean stepToTarget = this.shuttleLocMoveExecuteToTarget(wrkMast);//绉诲簱浠诲姟-灏忚溅鍘荤洰鏍囩偣 - if (!stepToTarget) { + boolean stepTake = this.shuttleLocMoveExecuteTake(wrkMast);//绉诲簱浠诲姟-灏忚溅鍙栬揣涓� + if (!stepTake) { + continue; + } + + boolean stepPut = this.shuttleLocMoveExecutePut(wrkMast);//绉诲簱浠诲姟-灏忚溅鍙栬揣涓� + if (!stepPut) { + continue; + } + + boolean stepComplete = this.shuttleLocMoveComplete(wrkMast);//绉诲簱浠诲姟-浠诲姟瀹屾垚 + if (!stepComplete) { continue; } @@ -505,22 +544,46 @@ } /** - * 绉诲簱浠诲姟-灏忚溅鍘荤洰鏍囩偣 + * 绉诲簱浠诲姟-灏忚溅鍙栬揣涓� * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue */ - private boolean shuttleLocMoveExecuteToTarget(WrkMast wrkMast) { + private boolean shuttleLocMoveExecuteTake(WrkMast wrkMast) { //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------// Date now = new Date(); - //灏忚溅绉诲姩鑷崇珯鐐� 501.鐢熸垚绉诲簱浠诲姟 ==> 502.灏忚溅鎼繍涓� + //灏忚溅绉诲姩鑷崇珯鐐� 501.鐢熸垚绉诲簱浠诲姟 ==> 502.灏忚溅鍙栬揣涓� if (wrkMast.getWrkSts() == WrkStsType.NEW_LOC_MOVE.sts) { if (wrkMast.getShuttleNo() == null) {//娌℃湁缁戝畾灏忚溅锛岃繘琛岃皟搴� boolean result = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//璋冨害灏忚溅鍒拌揣鐗╃偣杩涜鍙栬揣 News.info("{}浠诲姟锛岃皟搴﹀皬杞}绯荤粺绛夊緟涓�", wrkMast.getWrkNo(), result ? "鎴愬姛" : "澶辫触"); + + if (result) { + wrkMast.setWrkSts(WrkStsType.LOC_MOVE_SHUTTLE_TAKE.sts);//灏忚溅鎼繍涓� 501.鐢熸垚绉诲簱浠诲姟 ==> 502.灏忚溅鍙栬揣涓� + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + if (wrkMastService.updateById(wrkMast)) { + return false; + } + } + return false; } + } + return true; + } + /** + * 绉诲簱浠诲姟-灏忚溅鏀捐揣涓� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleLocMoveExecutePut(WrkMast wrkMast) { + //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------// + Date now = new Date(); + + //灏忚溅绉诲姩鑷崇珯鐐� 502.灏忚溅鍙栬揣涓� ==> 503.灏忚溅鏀捐揣涓� + if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_SHUTTLE_TAKE.sts) { //鑾峰彇鍥涘悜绌挎杞︾嚎绋� ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); if (shuttleThread == null) { @@ -536,44 +599,16 @@ return false; } - ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); - assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� - assignCommand.setTaskMode(ShuttleTaskModeType.TRANSPORT.id);//灏忚溅绉诲簱浠诲姟 - assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� - assignCommand.setAuto(true);//鑷姩妯″紡 + boolean result = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), null, wrkMast.getLocNo(), wrkMast.getShuttleNo(), "TRANSPORT");//璋冨害灏忚溅鏀捐揣 + News.info("{}浠诲姟锛岃皟搴﹀皬杞}绯荤粺绛夊緟涓�", wrkMast.getWrkNo(), result ? "鎴愬姛" : "澶辫触"); - //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); - if (commands == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); - return false; - } - - List<ShuttleCommand> liftCommand = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, true); - if (liftCommand == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇椤跺崌鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); - return false; - } - - List<ShuttleCommand> liftCommand2 = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, false); - if (liftCommand2 == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇涓嬮檷鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); - return false; - } - - commands.add(0, liftCommand.get(0)); - commands.add(liftCommand2.get(0)); - assignCommand.setCommands(commands); - - wrkMast.setWrkSts(WrkStsType.LOC_MOVE_SHUTTLE_RUN.sts);//灏忚溅鎼繍涓� 501.鐢熸垚绉诲簱浠诲姟 ==> 502.灏忚溅鎼繍涓� - wrkMast.setModiTime(now); - wrkMast.setSystemMsg("");//娓呯┖娑堟伅 - if (wrkMastService.updateById(wrkMast)) { - //涓嬪彂浠诲姟 - shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); - //瑙﹀彂閫氱煡 - notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); - return false; + if (result) { + wrkMast.setWrkSts(WrkStsType.LOC_MOVE_SHUTTLE_PUT.sts);//灏忚溅鎼繍涓� 502.灏忚溅鍙栬揣涓� ==> 503.灏忚溅鏀捐揣涓� + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + if (wrkMastService.updateById(wrkMast)) { + return false; + } } return false; } @@ -581,305 +616,428 @@ } /** - * 璐у弶鎻愬崌鏈轰换鍔� - */ - public synchronized void forkLiftIoExecute() { - try { - //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔� - List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .in("wrk_sts", WrkStsType.NEW_INBOUND.sts, WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts)); - if (wrkMasts.isEmpty()) { - return; - } - - for (WrkMast wrkMast : wrkMasts) { - Integer liftNo = wrkMast.getLiftNo(); - if (liftNo == null) { - //鏈垎閰嶆彁鍗囨満 - Integer staNo = wrkMast.getIoType() == WrkIoType.IN.id ? wrkMast.getSourceStaNo() : wrkMast.getStaNo(); - liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo); - if(liftNo == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); - continue; - } - - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - - if (!forkLiftThread.isIdle()) { - News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftNo); - continue; - } - - //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 - WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); - if (liftWrkMast != null) { - if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); - continue;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� - } - } - - wrkMast.setLiftNo(liftNo); - wrkMast.setModiTime(new Date()); - wrkMastService.updateById(wrkMast); - continue; - } - - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - - if (!forkLiftThread.isIdle()) { - News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftNo); - continue; - } - - boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//鎻愬崌鏈哄叆搴� - if (!stepIn) { - continue; - } - - boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//鎻愬崌鏈哄嚭搴� - if (!stepOut) { - continue; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 鎻愬崌鏈哄叆搴� + * 绉诲簱浠诲姟-浠诲姟瀹屾垚 * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue */ - private boolean liftIoExecuteStepIn(WrkMast wrkMast) { - //--------------------------------------鎻愬崌鏈哄叆搴�-----------------------------------------// + private boolean shuttleLocMoveComplete(WrkMast wrkMast) { + //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------// Date now = new Date(); - //1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑 - if (wrkMast.getWrkSts() == WrkStsType.NEW_INBOUND.sts) { - //鑾峰彇鐩爣杈撻�佺珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); - if (liftSta == null) { - return false;//鎵句笉鍒扮珯鐐� - } - - if (liftSta.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo()); - return false; - } - - if (liftSta.getHasCar()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪灏忚溅", wrkMast.getWrkNo()); - return false; - } - - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSta.getLiftNo()); - if (forkLiftThread == null) { - return false; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return false; - } - if (!forkLiftThread.isIdle()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo()); - return false; - } - - //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡叆搴撴ā寮� - if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡叆搴撴ā寮忥紝绂佹鍏ュ簱", wrkMast.getWrkNo()); - return false; - } - - //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 - WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); - if (liftWrkMast != null) { - if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); - return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� - } - } - - //妫�娴嬫ゼ灞傛槸鍚︽湁鍙敤绌挎杞� - boolean checkLevHasShuttle = Utils.checkLevHasShuttle(liftSta.getLev()); - if (!checkLevHasShuttle) { - if (wrkMast.getShuttleNo() != null) { - return false; - } - - //鑾峰彇灏忚溅寰呮満浣� - String standbyLocNo = Utils.getShuttleStandbyLocNo(liftSta.getLocNo()); - if (standbyLocNo == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃幏鍙栧皬杞﹀緟鏈轰綅澶辫触", wrkMast.getWrkNo()); - return false; - } - - //璋冨害灏忚溅鍘诲緟鏈轰綅 - boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), standbyLocNo); - if (!dispatchShuttle) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃皟搴﹀皬杞﹀け璐�", wrkMast.getWrkNo()); - return false; - } - return false; - } - - //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿叆搴� - boolean inMission = ForkLiftUtils.queryInMission(wrkMast.getSourceStaNo(), liftSta.getLiftNo(), wrkMast.getWmsWrkNo()); - if (!inMission) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屼笂绾х郴缁熶笉鍏佽鍏ュ簱", wrkMast.getWrkNo()); - return false; - } - - //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommands); - - //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 - LiftAssignCommand assignCommand = new LiftAssignCommand(); - assignCommand.setCommands(commands); - assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); - assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); - - wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑 - wrkMast.setSystemMsg("");//娓呯┖娑堟伅 - wrkMast.setModiTime(now); - if (wrkMastService.updateById(wrkMast)) { - //涓嬪彂浠诲姟 - forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); - } - return false; - } - return true; - } - - /** - * 鎻愬崌鏈哄嚭搴� - * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false - * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue - */ - private boolean liftIoExecuteStepOut(WrkMast wrkMast) { - //--------------------------------------鎻愬崌鏈哄嚭搴�-----------------------------------------// - //103.灏忚溅鎼繍瀹屾垚 ==> 104.鎻愬崌鏈烘惉杩愪腑 - if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts) { + //灏忚溅绉诲姩鑷崇珯鐐� 503.灏忚溅鏀捐揣涓� ==> 509.绉诲簱瀹屾垚 + if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_SHUTTLE_PUT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); if (shuttleThread == null) { return false; } ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); - if(shuttleProtocol == null) { + if (shuttleProtocol == null) { return false; } - //鑾峰彇婧愮珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); - if (liftSta == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾壘涓嶅埌绔欑偣锛岀姝㈡淳鍙�", wrkMast.getWrkNo()); - return false;//鎵句笉鍒扮珯鐐� - } - - if (shuttleProtocol.getCurrentLocNo().equals(liftSta.getLocNo())) { - //灏忚溅杩樺湪杈撻�佺珯鐐� - //鑾峰彇灏忚溅寰呮満浣� - String standbyLocNo = Utils.getShuttleStandbyLocNo(liftSta.getLocNo()); - if(standbyLocNo == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃幏鍙栧皬杞﹀緟鏈轰綅澶辫触", wrkMast.getWrkNo()); - return false; - } - //璋冨害灏忚溅鍘诲緟鏈轰綅 - boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), standbyLocNo, wrkMast.getShuttleNo()); - if (!dispatchShuttle) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀湪杈撻�佺珯鐐硅皟搴﹀皬杞﹂伩璁╁け璐�", wrkMast.getWrkNo()); - return false; - } - } - - if (liftSta.getHasCar()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣瀛樺湪灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftSta.getStaNo()); + if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞︽湭鍒拌揪鏀捐揣浣嶇疆", wrkMast.getWrkNo()); return false; } - if (!liftSta.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣鏃犳墭鐩橈紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getStaNo()); + if (shuttleProtocol.getHasLift()) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀浜庨《鍗囩姸鎬�", wrkMast.getWrkNo()); return false; } - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSta.getLiftNo()); - if (forkLiftThread == null) { - return false; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return false; - } - if (!forkLiftThread.isIdle()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo()); - return false; - } - - //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡嚭搴撴ā寮� - if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡嚭搴撴ā寮忥紝绂佹鍑哄簱", wrkMast.getWrkNo()); - return false; - } - - //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 - WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); - if (liftWrkMast != null) { - if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); - return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� - } - } - - //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿嚭搴� - boolean outMission = ForkLiftUtils.queryOutMission(wrkMast.getStaNo()); - if (!outMission) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屼笂绾х郴缁熶笉鍏佽鍑哄簱", wrkMast.getWrkNo()); - return false; - } - - //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo()); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommands); - - //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 - LiftAssignCommand assignCommand = new LiftAssignCommand(); - assignCommand.setCommands(commands); - assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); - assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); - - wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 103.鐢熸垚鍏ュ簱浠诲姟 ==> 104.鎻愬崌鏈烘惉杩愪腑 - wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 + wrkMast.setWrkSts(WrkStsType.COMPLETE_LOC_MOVE.sts);//灏忚溅鎼繍涓� 503.灏忚溅鏀捐揣涓� ==> 509.绉诲簱瀹屾垚 + wrkMast.setModiTime(now); wrkMast.setSystemMsg("");//娓呯┖娑堟伅 - wrkMast.setModiTime(new Date()); if (wrkMastService.updateById(wrkMast)) { - //涓嬪彂浠诲姟 - forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + return false; } return false; } return true; } + +// /** +// * 璐у弶鎻愬崌鏈轰换鍔� +// */ +// public synchronized void forkLiftIoExecute() { +// try { +// //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔� +// List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() +// .in("wrk_sts", WrkStsType.NEW_INBOUND.sts, WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts)); +// if (wrkMasts.isEmpty()) { +// return; +// } +// +// for (WrkMast wrkMast : wrkMasts) { +// Integer liftNo = wrkMast.getLiftNo(); +// if (liftNo == null) { +// //鏈垎閰嶆彁鍗囨満 +// Integer staNo = wrkMast.getIoType() == WrkIoType.IN.id ? wrkMast.getSourceStaNo() : wrkMast.getStaNo(); +// liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo); +// if(liftNo == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); +// continue; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// +// if (!forkLiftThread.isIdle()) { +// News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftNo); +// continue; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 +// WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); +// if (liftWrkMast != null) { +// if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// continue;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� +// } +// } +// +// wrkMast.setLiftNo(liftNo); +// wrkMast.setModiTime(new Date()); +// wrkMastService.updateById(wrkMast); +// continue; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// +// if (!forkLiftThread.isIdle()) { +// News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftNo); +// continue; +// } +// +// boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//鎻愬崌鏈哄叆搴� +// if (!stepIn) { +// continue; +// } +// +// boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//鎻愬崌鏈哄嚭搴� +// if (!stepOut) { +// continue; +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + +// /** +// * 鎻愬崌鏈哄叆搴� +// * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false +// * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue +// */ +// private boolean liftIoExecuteStepIn(WrkMast wrkMast) { +// //--------------------------------------鎻愬崌鏈哄叆搴�-----------------------------------------// +// Date now = new Date(); +// +// //1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑 +// if (wrkMast.getWrkSts() == WrkStsType.NEW_INBOUND.sts) { +// //鑾峰彇鐩爣杈撻�佺珯 +// ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); +// if (liftSta == null) { +// return false;//鎵句笉鍒扮珯鐐� +// } +// +// if (liftSta.getHasTray()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo()); +// return false; +// } +// +// if (liftSta.getHasCar()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪灏忚溅", wrkMast.getWrkNo()); +// return false; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSta.getLiftNo()); +// if (forkLiftThread == null) { +// return false; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return false; +// } +// if (!forkLiftThread.isIdle()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo()); +// return false; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡叆搴撴ā寮� +// if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡叆搴撴ā寮忥紝绂佹鍏ュ簱", wrkMast.getWrkNo()); +// return false; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 +// WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); +// if (liftWrkMast != null) { +// if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� +// } +// } +// +// //妫�娴嬫ゼ灞傛槸鍚︽湁鍙敤绌挎杞� +// boolean checkLevHasShuttle = Utils.checkLevHasShuttle(liftSta.getLev()); +// if (!checkLevHasShuttle) { +// if (wrkMast.getShuttleNo() != null) { +// return false; +// } +// +// //鑾峰彇灏忚溅寰呮満浣� +// String standbyLocNo = Utils.getShuttleStandbyLocNo(liftSta.getLocNo()); +// if (standbyLocNo == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃幏鍙栧皬杞﹀緟鏈轰綅澶辫触", wrkMast.getWrkNo()); +// return false; +// } +// +// //璋冨害灏忚溅鍘诲緟鏈轰綅 +// boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), standbyLocNo); +// if (!dispatchShuttle) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃皟搴﹀皬杞﹀け璐�", wrkMast.getWrkNo()); +// return false; +// } +// return false; +// } +// +// //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿叆搴� +// boolean inMission = ForkLiftUtils.queryInMission(wrkMast.getSourceStaNo(), liftSta.getLiftNo(), wrkMast.getWmsWrkNo()); +// if (!inMission) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屼笂绾х郴缁熶笉鍏佽鍏ュ簱", wrkMast.getWrkNo()); +// return false; +// } +// +// //鑾峰彇鎻愬崌鏈哄懡浠� +// List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); +// ArrayList<ForkLiftCommand> commands = new ArrayList<>(); +// commands.addAll(liftCommands); +// +// //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 +// LiftAssignCommand assignCommand = new LiftAssignCommand(); +// assignCommand.setCommands(commands); +// assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); +// assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); +// assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); +// +// wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑 +// wrkMast.setSystemMsg("");//娓呯┖娑堟伅 +// wrkMast.setModiTime(now); +// if (wrkMastService.updateById(wrkMast)) { +// //涓嬪彂浠诲姟 +// forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); +// } +// return false; +// } +// return true; +// } + +// /** +// * 鎻愬崌鏈轰换鍔� +// */ +// public synchronized void liftIoExecute() { +// try { +// //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔� +// List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() +// .in("wrk_sts", WrkStsType.NEW_INBOUND.sts, WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts)); +// if (wrkMasts.isEmpty()) { +// return; +// } +// +// for (WrkMast wrkMast : wrkMasts) { +// Integer liftNo = wrkMast.getLiftNo(); +// if (liftNo == null) { +// //鏈垎閰嶆彁鍗囨満 +// Integer staNo = wrkMast.getIoType() == WrkIoType.IN.id ? wrkMast.getSourceStaNo() : wrkMast.getStaNo(); +// liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo); +// if(liftNo == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); +// continue; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// +// if (!forkLiftThread.isIdle()) { +// News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftNo); +// continue; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 +// WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); +// if (liftWrkMast != null) { +// if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// continue;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� +// } +// } +// +// wrkMast.setLiftNo(liftNo); +// wrkMast.setModiTime(new Date()); +// wrkMastService.updateById(wrkMast); +// continue; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// continue; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// continue; +// } +// +// if (!forkLiftThread.isIdle()) { +// News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftNo); +// continue; +// } +// +// boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//鎻愬崌鏈哄叆搴� +// if (!stepIn) { +// continue; +// } +// +// boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//鎻愬崌鏈哄嚭搴� +// if (!stepOut) { +// continue; +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + +// /** +// * 鎻愬崌鏈哄嚭搴� +// * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false +// * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue +// */ +// private boolean liftIoExecuteStepOut(WrkMast wrkMast) { +// //--------------------------------------鎻愬崌鏈哄嚭搴�-----------------------------------------// +// //103.灏忚溅鎼繍瀹屾垚 ==> 104.鎻愬崌鏈烘惉杩愪腑 +// if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts) { +// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); +// if (shuttleThread == null) { +// return false; +// } +// ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); +// if(shuttleProtocol == null) { +// return false; +// } +// +// //鑾峰彇婧愮珯 +// ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); +// if (liftSta == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾壘涓嶅埌绔欑偣锛岀姝㈡淳鍙�", wrkMast.getWrkNo()); +// return false;//鎵句笉鍒扮珯鐐� +// } +// +// if (shuttleProtocol.getCurrentLocNo().equals(liftSta.getLocNo())) { +// //灏忚溅杩樺湪杈撻�佺珯鐐� +// //鑾峰彇灏忚溅寰呮満浣� +// String standbyLocNo = Utils.getShuttleStandbyLocNo(liftSta.getLocNo()); +// if(standbyLocNo == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃幏鍙栧皬杞﹀緟鏈轰綅澶辫触", wrkMast.getWrkNo()); +// return false; +// } +// //璋冨害灏忚溅鍘诲緟鏈轰綅 +// boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), standbyLocNo, wrkMast.getShuttleNo()); +// if (!dispatchShuttle) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀湪杈撻�佺珯鐐硅皟搴﹀皬杞﹂伩璁╁け璐�", wrkMast.getWrkNo()); +// return false; +// } +// } +// +// if (liftSta.getHasCar()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣瀛樺湪灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftSta.getStaNo()); +// return false; +// } +// +// if (!liftSta.getHasTray()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣鏃犳墭鐩橈紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getStaNo()); +// return false; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSta.getLiftNo()); +// if (forkLiftThread == null) { +// return false; +// } +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return false; +// } +// if (!forkLiftThread.isIdle()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo()); +// return false; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡嚭搴撴ā寮� +// if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡嚭搴撴ā寮忥紝绂佹鍑哄簱", wrkMast.getWrkNo()); +// return false; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 +// WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); +// if (liftWrkMast != null) { +// if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� +// } +// } +// +// //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿嚭搴� +// boolean outMission = ForkLiftUtils.queryOutMission(wrkMast.getStaNo()); +// if (!outMission) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屼笂绾х郴缁熶笉鍏佽鍑哄簱", wrkMast.getWrkNo()); +// return false; +// } +// +// //鑾峰彇鎻愬崌鏈哄懡浠� +// List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo()); +// ArrayList<ForkLiftCommand> commands = new ArrayList<>(); +// commands.addAll(liftCommands); +// +// //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 +// LiftAssignCommand assignCommand = new LiftAssignCommand(); +// assignCommand.setCommands(commands); +// assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); +// assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); +// assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue()); +// +// wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 103.鐢熸垚鍏ュ簱浠诲姟 ==> 104.鎻愬崌鏈烘惉杩愪腑 +// wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 +// wrkMast.setSystemMsg("");//娓呯┖娑堟伅 +// wrkMast.setModiTime(new Date()); +// if (wrkMastService.updateById(wrkMast)) { +// //涓嬪彂浠诲姟 +// forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); +// } +// return false; +// } +// return true; +// } /** * 璐у弶鎻愬崌鏈轰换鍔″畬鎴� @@ -923,6 +1081,67 @@ News.info("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬併�傛彁鍗囨満鍙�={}", forkLiftProtocol.getLiftNo()); } else { News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", forkLiftProtocol.getLiftNo(), forkLiftProtocol.getWrkNo()); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 鎻愬崌鏈轰换鍔″畬鎴� + */ + public synchronized void liftFinished() { + try { + for (LiftSlave slave : slaveProperties.getLift()) { + //鑾峰彇鎻愬崌鏈轰俊鎭� + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + continue; + } + + //鎻愬崌鏈轰负绛夊緟纭涓旂┖闂� + if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id + && liftProtocol.getTaskNo() != 0 + ) { + //灏嗕换鍔℃。鏍囪涓哄畬鎴� + WrkMast wrkMast = wrkMastService.selectByWorkNo(liftProtocol.getTaskNo()); + if (wrkMast != null) { + if (wrkMast.getWrkSts() == WrkStsType.INBOUND_LIFT_RUN.sts) { + //3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴� + wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts); + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_LIFT_RUN.sts) { + //104.鎻愬崌鏈烘惉杩愪腑 ==> 109.鍑哄簱瀹屾垚 + wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts); + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_RUN.sts) { + //306.鎻愬崌鏈烘惉杩愪腑 ==> 307.鎻愬崌鏈烘惉杩愬畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN_COMPLETE.sts); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_TO_SHUTTLE_TRANSPORT_LIFT.sts) { + //鎻愬崌鏈鸿嚦灏忚溅灞� ==> 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT.sts); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_TO_TARGET_TRANSPORT_LIFT.sts) { + //鎻愬崌鏈鸿嚦鏀捐揣灞� ==> 鎻愬崌鏈鸿嚦鏀捐揣灞傚畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_TARGET_COMPLETE_TRANSPORT_LIFT.sts); + } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_TO_SHUTTLE_TRANSPORT_LIFT_OUT.sts) { + //鎻愬崌鏈鸿嚦灏忚溅灞� ==> 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT_OUT.sts); + } + + wrkMast.setModiTime(new Date()); + if (wrkMastService.updateById(wrkMast)) { + liftThread.setSyncTaskNo(0); + liftThread.setProtocolStatus(LiftProtocolStatusType.IDLE); + News.info("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬併�傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo()); + } else { + News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); } } } @@ -1021,29 +1240,29 @@ */ private void recLiftErr() { Date now = new Date(); - for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) { + for (LiftSlave slave : slaveProperties.getLift()) { // 鑾峰彇鎻愬崌鏈轰俊鎭� - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId()); - if (forkLiftThread == null) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); + if (liftThread == null) { continue; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { continue; } - if (forkLiftProtocol.getTaskNo() != 0) { + if (liftProtocol.getTaskNo() != 0) { //鏈変换鍔� - BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(forkLiftSlave.getId(), forkLiftProtocol.getTaskNo()); + BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(slave.getId(), liftProtocol.getTaskNo()); // 鏈夊紓甯� if (latest == null) { - if (forkLiftProtocol.getErrorCode() != null && forkLiftProtocol.getErrorCode() != 0) { - WrkMast wrkMast = wrkMastService.selectByWorkNo(forkLiftProtocol.getWrkNo()); + if (liftProtocol.getErrorCode() != null && !liftProtocol.getErrorCode().equals("0")) { + WrkMast wrkMast = wrkMastService.selectByWorkNo(liftProtocol.getTaskNo()); if (wrkMast == null) { continue; } - BasLiftErr basLiftErr = basLiftErrService.queryByCode(forkLiftProtocol.getErrorCode()); + BasLiftErr basLiftErr = basLiftErrService.queryByCode(Integer.parseInt(liftProtocol.getErrorCode())); String errName = basLiftErr==null? "鏈煡寮傚父":basLiftErr.getErrName(); BasLiftErrLog basLiftErrLog = new BasLiftErrLog( @@ -1053,7 +1272,7 @@ null, // 缁撴潫鏃堕棿 wrkMast.getWrkSts(), // 宸ヤ綔鐘舵�� wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨� - forkLiftSlave.getId(), // 鎻愬崌鏈� + slave.getId(), // 鎻愬崌鏈� null, // plc wrkMast.getLocNo(), // 鐩爣搴撲綅 wrkMast.getStaNo(), // 鐩爣绔� @@ -1068,20 +1287,20 @@ now, // 淇敼鏃堕棿 null, // 淇敼浜哄憳 "浠诲姟涓紓甯�", // 澶囨敞 - JSON.toJSONString(forkLiftProtocol) // 绯荤粺鐘舵�佹暟鎹� + JSON.toJSONString(liftProtocol) // 绯荤粺鐘舵�佹暟鎹� ); if (!basLiftErrLogService.insert(basLiftErrLog)) { - News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", forkLiftSlave.getId(), errName); + News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", slave.getId(), errName); } } } else { // 寮傚父淇 - if (forkLiftProtocol.getErrorCode() == null || forkLiftProtocol.getErrorCode() == 0) { + if (liftProtocol.getErrorCode() == null || liftProtocol.getErrorCode().equals("0")) { latest.setEndTime(now); latest.setUpdateTime(now); latest.setStatus(2); if (!basLiftErrLogService.updateById(latest)) { - News.error("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", forkLiftSlave.getId(), latest.getId()); + News.error("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", slave.getId(), latest.getId()); } } } @@ -1413,30 +1632,1235 @@ //鏌ヨ灏忚溅绉诲簱浠诲姟 List<WrkMast> wrkMasts = wrkMastService.selectShuttleMoveWrk(); for (WrkMast wrkMast : wrkMasts) { - boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐� - if (!stepMoveSta) { - continue; - } + if ("TRANSPORT_LIFT".equals(wrkMast.getMk())) { + this.shuttleMoveExecuteTransportLift(wrkMast); + } else if ("TRANSPORT_DEVP".equals(wrkMast.getMk())) { - boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//鎻愬崌鏈烘惉杩愪腑 - if (!stepLiftMove) { - continue; + }else { + this.shuttleMoveExecuteMove(wrkMast); } - - boolean updateShuttleLocation = this.shuttleMoveExecuteStepUpdateShuttleLocation(wrkMast);//鎻愬崌鏈烘惉杩愬畬鎴愭洿鏂板皬杞﹀潗鏍� - if (!updateShuttleLocation) { - continue; - } - - boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 - if (!stepMoveLoc) { - continue; - } - } } catch (Exception e) { e.printStackTrace(); } + } + + private void shuttleMoveExecuteMove(WrkMast wrkMast) { + boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐� + if (!stepMoveSta) { + return; + } + + boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈� + if (!stepIntoLift) { + return; + } + + boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//鎻愬崌鏈烘惉杩愪腑 + if (!stepLiftMove) { + return; + } + + boolean updateShuttleLocation = this.shuttleMoveExecuteStepUpdateShuttleLocation(wrkMast);//鎻愬崌鏈烘惉杩愬畬鎴愭洿鏂板皬杞﹀潗鏍� + if (!updateShuttleLocation) { + return; + } + + boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 + if (!stepMoveLoc) { + return; + } + } + + private void shuttleMoveExecuteTransportLift(WrkMast wrkMast) { + LiftThread liftThread = LiftUtils.getRecentLift(wrkMast.getLocNo()); + if (liftThread == null) { + return; + } + + String liftLocNo = liftThread.getLiftLocNo(Utils.getLev(wrkMast.getLocNo())); + if (Utils.getRow(liftLocNo) == Utils.getRow(wrkMast.getSourceLocNo()) && Utils.getBay(liftLocNo) == Utils.getBay(wrkMast.getSourceLocNo())) { + //鍙栬揣浣嶇疆鏄彁鍗囨満 + this.shuttleMoveExecuteTransportLiftTake(wrkMast); + }else { + //鏀捐揣浣嶇疆鏄彁鍗囨満 + this.shuttleMoveExecuteTransportLiftPut(wrkMast); + } + } + + private void shuttleMoveExecuteTransportLiftTake(WrkMast wrkMast) { + boolean stepMoveSta = this.shuttleMoveExecuteTransportLiftStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐� + if (!stepMoveSta) { + return; + } + + boolean stepLiftToShuttleLev = this.shuttleMoveExecuteTransportLiftStepLiftToShuttleLev(wrkMast);//鎻愬崌鏈哄埌灏忚溅灞� + if (!stepLiftToShuttleLev) { + return; + } + + boolean stepIntoLift = this.shuttleMoveExecuteTransportLiftStepIntoLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈� + if (!stepIntoLift) { + return; + } + + boolean stepLiftToTargetLev = this.shuttleMoveExecuteTransportLiftStepLiftToTargetLev(wrkMast);//鎻愬崌鏈哄埌鏀捐揣灞� + if (!stepLiftToTargetLev) { + return; + } + + boolean stepOutLift = this.shuttleMoveExecuteTransportLiftStepOutLift(wrkMast);//灏忚溅杩佸嚭鎻愬崌鏈� + if (!stepOutLift) { + return; + } + + boolean stepMoveLoc = this.shuttleMoveExecuteTransportLiftStepMoveLoc(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 + if (!stepMoveLoc) { + return; + } + } + + /** + * 灏忚溅杩佺Щ-鍛煎彨灏忚溅鑷冲彇璐х偣 + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepCallShuttle(WrkMast wrkMast) { + Date now = new Date(); + //灏忚溅绉诲姩鑷崇珯鐐� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 鍛煎彨灏忚溅鑷冲彇璐х偣 + if (wrkMast.getWrkSts() == WrkStsType.NEW_MOVE.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + return false; + } + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { + //灏忚溅鍦ㄥ彇璐х偣 + wrkMast.setWrkSts(WrkStsType.CALL_SHUTTLE_TO_TAKE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 鍛煎彨灏忚溅鑷冲彇璐х偣 + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMastService.updateById(wrkMast); + return false; + } + + boolean dispatchShuttle = shuttleDispatchUtils.shuttleMoveGenerate(wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo(), null, true); + if (!dispatchShuttle) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃皟搴﹁嚦鍙栬揣鐐瑰け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + wrkMast.setWrkSts(WrkStsType.CALL_SHUTTLE_TO_TAKE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 鍛煎彨灏忚溅鑷冲彇璐х偣 + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMastService.updateById(wrkMast); + return false; + } + return true; + } + + /** + * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒扮珯鐐� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftOutStepMoveSta(WrkMast wrkMast) { + //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------// + Date now = new Date(); + + //灏忚溅绉诲姩鑷崇珯鐐� 鍛煎彨灏忚溅鑷冲彇璐х偣 ==> 灏忚溅绉诲姩鑷崇珯鐐逛腑 + if (wrkMast.getWrkSts() == WrkStsType.CALL_SHUTTLE_TO_TAKE.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + return false; + } + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屾湭鍒拌揪鍙栬揣鐐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 + LiftThread liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); + if (liftThread == null) { + News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); + return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鑾峰彇鎻愬崌鏈哄緟鏈轰綅 + String liftStandByLocNo = liftThread.getLiftStandByLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + List<ShuttleCommand> commands = new ArrayList<>(); + Integer mapType = NavigationMapType.DFX.id; + + //鑾峰彇灏忚溅鍒版彁鍗囨満寰呮満浣嶈璧板懡浠� + List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftStandByLocNo, mapType, assignCommand, shuttleThread); + if (moveCommands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false;//璺緞瑙i攣澶辫触 + } + commands.addAll(moveCommands); + + List<ShuttleCommand> liftCommand = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, true); + if (liftCommand == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇椤跺崌鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + commands.addAll(0, liftCommand); + + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_SITE_TRANSPORT_LIFT_OUT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 鍛煎彨灏忚溅鑷冲彇璐х偣 ==> 灏忚溅绉诲姩鑷崇珯鐐逛腑 + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + return false; + } + return false; + } + return true; + } + + /** + * 灏忚溅杩佺Щ-鎻愬崌鏈哄埌灏忚溅灞� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftOutStepLiftToShuttleLev(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 鎻愬崌鏈鸿嚦灏忚溅灞� + if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_COMPLETE_TRANSPORT_LIFT_OUT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + LiftThread liftThread = null; + LiftProtocol liftProtocol = null; + if (wrkMast.getLiftNo() == null) { + //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 + liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); + if (liftThread == null) { + News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); + return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(liftProtocol.getLiftNo()); + if (liftWrkMast != null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + + wrkMast.setModiTime(now); + wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMastService.updateById(wrkMast); + return false; + }else { + liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈烘ゼ灞� + if (liftProtocol.getLev() == Utils.getLev(shuttleProtocol.getCurrentLocNo())) { + //鎻愬崌鏈哄湪灏忚溅妤煎眰 + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT_OUT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� + wrkMast.setModiTime(now); + wrkMastService.updateById(wrkMast); + return false; + } + + //璋冨害鎻愬崌鏈� + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommands = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), Utils.getLev(shuttleProtocol.getCurrentLocNo()), LiftCommandModeType.MOVE); + LiftCommand liftCommand = liftCommands.get(0); + + int deviceWrk = commonService.getWorkNo(8);//鐢熸垚鎻愬崌鏈鸿澶囧伐浣滃彿 + liftCommand.setTaskNo(deviceWrk);//鏇存崲闅忔満浠诲姟鍙� + + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); + assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); + + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_SHUTTLE_TRANSPORT_LIFT_OUT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 鎻愬崌鏈鸿嚦灏忚溅灞� + wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + return false; + } + return false; + } + + return true; + } + + /** + * 灏忚溅杩佺Щ-灏忚溅杩佸叆鎻愬崌鏈� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftOutStepIntoLift(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� ==> 灏忚溅杩佸叆鎻愬崌鏈轰腑 + if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT_OUT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟锛屾湭缁戝畾鎻愬崌鏈猴紝绂佹娲惧彂", wrkMast.getWrkNo()); + return false; + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.info("{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈烘ゼ灞� + if (liftProtocol.getLev() != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { + //鎻愬崌鏈轰笉鍦ㄥ皬杞︽ゼ灞� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満涓庡皬杞︿笉鍦ㄥ悓涓�灞傦紝绂佹娲惧彂", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//绛夊緟鎻愬崌鏈哄埌灏忚溅妤煎眰 + } + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + //鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护 + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getLiftLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + if (commands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + List<ShuttleCommand> liftCommand = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, false); + if (liftCommand == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇椤跺崌鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + commands.addAll(liftCommand); + + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT_TRANSPORT_LIFT_OUT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� ==> 灏忚溅杩佸叆鎻愬崌鏈轰腑 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + return false; + } + return false; + } + + return true; + } + + /** + * 灏忚溅杩佺Щ-灏忚溅杩佸嚭鎻愬崌鏈� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftOutStepOutLift(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 灏忚溅杩佸嚭鎻愬崌鏈轰腑 + if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_COMPLETE_TRANSPORT_LIFT_OUT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟锛屾彁鍗囨満鏈粦瀹氾紝绂佹娲惧彂", wrkMast.getWrkNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.info("{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (!liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (!liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + //鑾峰彇鎻愬崌鏈哄緟鏈轰綅 + String liftStandByLocNo = liftThread.getLiftStandByLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); + + //鑾峰彇灏忚溅鍒版彁鍗囨満寰呮満琛岃蛋鍛戒护 + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftStandByLocNo, NavigationMapType.DFX.id, assignCommand, shuttleThread); + if (commands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_TRANSPORT_LIFT_OUT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦鏀捐揣灞傚畬鎴� ==> 灏忚溅杩佸嚭鎻愬崌鏈轰腑 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + return false; + } + return false; + } + + return true; + } + + private void shuttleMoveExecuteTransportLiftPut(WrkMast wrkMast) { + boolean stepMoveSta = this.shuttleMoveExecuteTransportLiftStepCallShuttle(wrkMast);//鍛煎彨灏忚溅鑷冲彇璐х偣 + if (!stepMoveSta) { + return; + } + + boolean stepTransportLiftOutStepMoveSta = this.shuttleMoveExecuteTransportLiftOutStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐� + if (!stepTransportLiftOutStepMoveSta) { + return; + } + + boolean stepLiftToShuttleLev = this.shuttleMoveExecuteTransportLiftOutStepLiftToShuttleLev(wrkMast);//鎻愬崌鏈哄埌灏忚溅灞� + if (!stepLiftToShuttleLev) { + return; + } + + boolean stepIntoLift = this.shuttleMoveExecuteTransportLiftOutStepIntoLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈� + if (!stepIntoLift) { + return; + } + + boolean stepOutLift = this.shuttleMoveExecuteTransportLiftOutStepOutLift(wrkMast);//灏忚溅杩佸嚭鎻愬崌鏈� + if (!stepOutLift) { + return; + } + } + + /** + * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒扮珯鐐� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepMoveSta(WrkMast wrkMast) { + //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------// + Date now = new Date(); + + //灏忚溅绉诲姩鑷崇珯鐐� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 灏忚溅绉诲姩鑷崇珯鐐逛腑 + if (wrkMast.getWrkSts() == WrkStsType.NEW_MOVE.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + return false; + } + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 + LiftThread liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); + if (liftThread == null) { + News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); + return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鑾峰彇鎻愬崌鏈哄緟鏈轰綅 + String liftStandByLocNo = liftThread.getLiftStandByLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + List<ShuttleCommand> commands = new ArrayList<>(); + Integer mapType = NavigationMapType.NORMAL.id; + + if (shuttleProtocol.getCurrentLocNo().equals(liftStandByLocNo)) { + //灏忚溅鍦ㄥ緟鏈轰綅锛岀洿鎺ョЩ鍔ㄥ畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE_TRANSPORT_LIFT.sts);// 灏忚溅绉诲姩鑷崇珯鐐� ==> 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMastService.updateById(wrkMast); + return false; + } + + if (!liftStandByLocNo.equals(wrkMast.getSourceLocNo())) { + //鑾峰彇灏忚溅鍒版彁鍗囨満寰呮満浣嶈璧板懡浠� + List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftStandByLocNo, mapType, assignCommand, shuttleThread); + if (moveCommands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false;//璺緞瑙i攣澶辫触 + } + commands.addAll(moveCommands); + } + + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_SITE_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 322.灏忚溅绉诲姩鑷崇珯鐐� + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); + return false; + } + return false; + } + return true; + } + + /** + * 灏忚溅杩佺Щ-鎻愬崌鏈哄埌灏忚溅灞� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepLiftToShuttleLev(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 鎻愬崌鏈鸿嚦灏忚溅灞� + if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_COMPLETE_TRANSPORT_LIFT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + LiftThread liftThread = null; + LiftProtocol liftProtocol = null; + if (wrkMast.getLiftNo() == null) { + //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 + liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); + if (liftThread == null) { + News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); + return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(liftProtocol.getLiftNo()); + if (liftWrkMast != null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + + wrkMast.setModiTime(now); + wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMastService.updateById(wrkMast); + return false; + }else { + liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (!liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈烘ゼ灞� + if (liftProtocol.getLev() == Utils.getLev(shuttleProtocol.getCurrentLocNo())) { + //鎻愬崌鏈哄湪灏忚溅妤煎眰 + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� + wrkMast.setModiTime(now); + wrkMastService.updateById(wrkMast); + return false; + } + + //璋冨害鎻愬崌鏈� + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommands = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), Utils.getLev(shuttleProtocol.getCurrentLocNo()), LiftCommandModeType.MOVE); + LiftCommand liftCommand = liftCommands.get(0); + + int deviceWrk = commonService.getWorkNo(8);//鐢熸垚鎻愬崌鏈鸿澶囧伐浣滃彿 + liftCommand.setTaskNo(deviceWrk);//鏇存崲闅忔満浠诲姟鍙� + + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); + assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); + + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_SHUTTLE_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 鎻愬崌鏈鸿嚦灏忚溅灞� + wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Lift), liftProtocol.getLiftNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_IN_LIFT); + return false; + } + return false; + } + + return true; + } + + /** + * 灏忚溅杩佺Щ-灏忚溅杩佸叆鎻愬崌鏈� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepIntoLift(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� ==> 灏忚溅杩佸叆鎻愬崌鏈轰腑 + if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟锛屾湭缁戝畾鎻愬崌鏈猴紝绂佹娲惧彂", wrkMast.getWrkNo()); + return false; + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.info("{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (!liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈烘ゼ灞� + if (liftProtocol.getLev() != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { + //鎻愬崌鏈轰笉鍦ㄥ皬杞︽ゼ灞� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満涓庡皬杞︿笉鍦ㄥ悓涓�灞傦紝绂佹娲惧彂", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//绛夊緟鎻愬崌鏈哄埌灏忚溅妤煎眰 + } + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + //鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护 + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getLiftLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + if (commands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴� ==> 灏忚溅杩佸叆鎻愬崌鏈轰腑 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_IN_LIFT); + return false; + } + return false; + } + + return true; + } + + /** + * 灏忚溅杩佺Щ-鎻愬崌鏈哄埌鏀捐揣灞� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepLiftToTargetLev(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 鎻愬崌鏈鸿嚦鏀捐揣灞� + if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_COMPLETE_TRANSPORT_LIFT.sts) { + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟鏈粦瀹氭彁鍗囨満", wrkMast.getWrkNo()); + return false; + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (!liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (!liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + if (liftProtocol.getLev() == Utils.getLev(wrkMast.getLocNo())) { + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_TARGET_COMPLETE_TRANSPORT_LIFT.sts);// 灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 鎻愬崌鏈鸿嚦鏀捐揣灞傚畬鎴� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMast.setModiTime(now); + wrkMastService.updateById(wrkMast); + return false; + } + + //璋冨害鎻愬崌鏈� + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommands = liftThread.getMoveWithShuttleCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), Utils.getLev(wrkMast.getLocNo()), LiftCommandModeType.MOVE); + LiftCommand liftCommand = liftCommands.get(0); + + int deviceWrk = commonService.getWorkNo(8);//鐢熸垚鎻愬崌鏈鸿澶囧伐浣滃彿 + liftCommand.setTaskNo(deviceWrk);//鏇存崲闅忔満浠诲姟鍙� + + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); + assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); + + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_TO_TARGET_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 鎻愬崌鏈鸿嚦鏀捐揣灞� + wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Lift), liftProtocol.getLiftNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_IN_LIFT); + return false; + } + return false; + } + + return true; + } + + /** + * 灏忚溅杩佺Щ-灏忚溅杩佸嚭鎻愬崌鏈� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepOutLift(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦鏀捐揣灞傚畬鎴� ==> 灏忚溅杩佸嚭鎻愬崌鏈轰腑 + if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_TO_TARGET_COMPLETE_TRANSPORT_LIFT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟锛屾彁鍗囨満鏈粦瀹氾紝绂佹娲惧彂", wrkMast.getWrkNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.info("{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (!liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩� + if (!liftProtocol.getHasTray()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈烘ゼ灞� + if (liftProtocol.getLev() != Utils.getLev(wrkMast.getLocNo())) { + //鎻愬崌鏈轰笉鍦ㄦ斁璐у眰 + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屼笉鍦ㄦ斁璐у眰锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false; + } + + if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.UPDATE_LOCATION.id);//鏇存柊鍧愭爣 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣� + assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅 + + //鏇存柊灏忚溅鍧愭爣 + ShuttleCommand command = shuttleThread.getUpdateLocationCommand(wrkMast.getWrkNo(), wrkMast.getLocNo()); + ArrayList<ShuttleCommand> commands = new ArrayList<>(); + commands.add(command); + + assignCommand.setCommands(commands); + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + return false; + } + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + //鑾峰彇鎻愬崌鏈哄緟鏈轰綅 + String liftStandByLocNo = liftThread.getLiftStandByLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); + + //鑾峰彇灏忚溅鍒版彁鍗囨満寰呮満琛岃蛋鍛戒护 + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftStandByLocNo, NavigationMapType.DFX.id, assignCommand, shuttleThread); + if (commands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + List<ShuttleCommand> liftCommand = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, true); + if (liftCommand == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇椤跺崌鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + commands.addAll(0, liftCommand); + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 鎻愬崌鏈鸿嚦鏀捐揣灞傚畬鎴� ==> 灏忚溅杩佸嚭鎻愬崌鏈轰腑 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_IN_LIFT); + return false; + } + return false; + } + + return true; + } + + /** + * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteTransportLiftStepMoveLoc(WrkMast wrkMast) { + //--------------------------------------灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑-----------------------------------------// + Date now = new Date(); + + //灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 灏忚溅鏀捐揣涓� + if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT_COMPLETE_TRANSPORT_LIFT.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + return false; + } + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣� + assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅 + + List<ShuttleCommand> commands = new ArrayList<>(); + Integer mapType = NavigationMapType.DFX.id; + + List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), mapType, assignCommand, shuttleThread); + if (moveCommands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false;//璺緞璁$畻澶辫触 + } + commands.addAll(moveCommands); + + List<ShuttleCommand> liftCommand = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, false); + if (liftCommand == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇椤跺崌鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + commands.addAll(liftCommand); + + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_SHUTTLE_TRANSPORT_LIFT.sts);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 灏忚溅鏀捐揣涓� + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMast.setModiTime(now); + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + } + } + return true; } /** @@ -1477,29 +2901,308 @@ return false; } - //鑾峰彇婧愯緭閫佺珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); - if (liftSta == null) { - return false;//鎵句笉鍒扮珯鐐� + //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 + LiftThread liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); + if (liftThread == null) { + News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); + return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� } - if (wrkMast.getLiftNo() == null) { - //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) - WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(liftSta.getLiftNo()); - if (liftWrkMast != null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getLiftNo()); - return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� - } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + //鑾峰彇鎻愬崌鏈哄緟鏈轰綅 + String liftStandByLocNo = liftThread.getLiftStandByLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + + List<ShuttleCommand> commands = new ArrayList<>(); + Integer mapType = NavigationMapType.NORMAL.id; + + if (!liftStandByLocNo.equals(wrkMast.getSourceLocNo())) { + //鑾峰彇灏忚溅鍒版彁鍗囨満寰呮満浣嶈璧板懡浠� + List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftStandByLocNo, mapType, assignCommand, shuttleThread); + if (moveCommands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false;//璺緞瑙i攣澶辫触 + } + commands.addAll(moveCommands); + }else { + //灏忚溅鍦ㄥ緟鏈轰綅锛岀洿鎺ョЩ鍔ㄥ畬鎴� + wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE.sts);// 302.灏忚溅绉诲姩鑷崇珯鐐� ==> 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� wrkMast.setModiTime(now); - wrkMast.setLiftNo(liftSta.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� wrkMast.setSystemMsg("");//娓呯┖娑堟伅 wrkMastService.updateById(wrkMast); return false; } + assignCommand.setCommands(commands); + + wrkMast.setWrkSts(WrkStsType.MOVE_SITE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐� + wrkMast.setModiTime(now); + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + if (wrkMastService.updateById(wrkMast)) { + //涓嬪彂浠诲姟 + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + //瑙﹀彂閫氱煡 + notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); + return false; + } + return false; + } + return true; + } + +// /** +// * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒扮珯鐐� +// * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false +// * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue +// */ +// private boolean shuttleMoveExecuteStepMoveSta(WrkMast wrkMast) { +// //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------// +// Date now = new Date(); +// +// //灏忚溅绉诲姩鑷崇珯鐐� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐逛腑 +// if (wrkMast.getWrkSts() == WrkStsType.NEW_MOVE.sts) { +// //鑾峰彇鍥涘悜绌挎杞︾嚎绋� +// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); +// if (shuttleThread == null) { +// return false; +// } +// ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); +// if (shuttleProtocol == null) { +// return false; +// } +// +// //灏忚溅澶勪簬绌洪棽鐘舵�� +// if (!shuttleThread.isIdle()) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false; +// } +// +// //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 +// LiftThread liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); +// if (liftThread == null) { +// News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); +// return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� +// } +// +// LiftProtocol liftProtocol = liftThread.getStatus(); +// if (liftProtocol == null) { +// News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); +// return false; +// } +// +// //鑾峰彇鎻愬崌鏈轰綅 +// String liftLocNo = liftThread.getLiftLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); +// //鑾峰彇鎻愬崌鏈哄緟鏈轰綅 +// String liftStandByLocNo = liftThread.getLiftStandByLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())); +// +// if (!liftLocNo.equals(wrkMast.getLocNo()) && !liftLocNo.equals(shuttleProtocol.getCurrentLocNo())) { +// if (Utils.getLev(wrkMast.getLocNo()) == Utils.getLev(shuttleProtocol.getCurrentLocNo())) { +// //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庡悓涓�妤煎眰锛屼笉闇�瑕侀�氳繃鎻愬崌鏈鸿皟搴� +// wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_COMPLETE.sts);// 309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 310.灏忚溅绉诲姩涓� +// wrkMast.setModiTime(now); +// if (wrkMastService.updateById(wrkMast)) { +// //涓嬪彂浠诲姟 +// return true;//鐩存帴杩涘叆309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 310.灏忚溅绉诲姩涓� +// } +// return false; +// } +// } +// +// if (liftLocNo.equals(shuttleProtocol.getCurrentLocNo())) { +// //灏忚溅鍦ㄦ彁鍗囨満鍐� +// wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN_COMPLETE.sts);// 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 310.鎻愬崌鏈烘惉杩愬畬鎴� +// wrkMast.setModiTime(now); +// if (wrkMastService.updateById(wrkMast)) { +// //涓嬪彂浠诲姟 +// return true;//鐩存帴杩涘叆309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 310.灏忚溅绉诲姩涓� +// } +// return false; +// } +// +// ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); +// assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� +// assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 +// assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� +// assignCommand.setAuto(true);//鑷姩妯″紡 +// +// List<ShuttleCommand> commands = new ArrayList<>(); +// Integer mapType = NavigationMapType.NORMAL.id; +// //鎼繍璐х墿浠诲姟 +// if ("TRANSPORT".equals(wrkMast.getMk())) { +// mapType = NavigationMapType.DFX.id; +// +// List<ShuttleCommand> liftCommand = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, true); +// if (liftCommand == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅鑾峰彇椤跺崌鍛戒护澶辫触", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false; +// } +// commands.addAll(liftCommand); +// } +// +// if (!liftStandByLocNo.equals(wrkMast.getSourceLocNo())) { +// //鑾峰彇灏忚溅鍒版彁鍗囨満寰呮満浣嶈璧板懡浠� +// List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftStandByLocNo, mapType, assignCommand, shuttleThread); +// if (moveCommands == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false;//璺緞瑙i攣澶辫触 +// } +// commands.addAll(moveCommands); +// }else { +// //灏忚溅鍦ㄥ緟鏈轰綅锛岀洿鎺ョЩ鍔ㄥ畬鎴� +// wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE.sts);// 302.灏忚溅绉诲姩鑷崇珯鐐� ==> 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� +// wrkMast.setModiTime(now); +// wrkMast.setSystemMsg("");//娓呯┖娑堟伅 +// wrkMastService.updateById(wrkMast); +// return false; +// } +// +// assignCommand.setCommands(commands); +// +// wrkMast.setWrkSts(WrkStsType.MOVE_SITE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐� +// wrkMast.setModiTime(now); +// wrkMast.setSystemMsg("");//娓呯┖娑堟伅 +// if (wrkMastService.updateById(wrkMast)) { +// //涓嬪彂浠诲姟 +// shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); +// return false; +// } +// return false; +// } +// return true; +// } + + /** + * 灏忚溅杩佺Щ-灏忚溅杩佸叆鎻愬崌鏈� + * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false + * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue + */ + private boolean shuttleMoveExecuteStepIntoLift(WrkMast wrkMast) { + //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// + Date now = new Date(); + //灏忚溅绉诲姩鍒版彁鍗囨満涓� 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 304.灏忚溅杩佸叆鎻愬崌鏈轰腑 + if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_COMPLETE.sts) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + LiftThread liftThread = null; + LiftProtocol liftProtocol = null; + if (wrkMast.getLiftNo() == null) { + //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 + liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); + if (liftThread == null) { + News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); + return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(liftProtocol.getLiftNo()); + if (liftWrkMast != null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + + wrkMast.setModiTime(now); + wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� + wrkMast.setSystemMsg("");//娓呯┖娑堟伅 + wrkMastService.updateById(wrkMast); + return false; + }else { + liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); + return false; + } + } + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + if (!liftThread.isIdle()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //灏忚溅澶勪簬绌洪棽鐘舵�� + if (!shuttleThread.isIdle()) { + News.info("{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� + } + + //鍒ゆ柇鎻愬崌鏈烘ゼ灞� + if (liftProtocol.getLev() != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { + //鎻愬崌鏈轰笉鍦ㄥ皬杞︽ゼ灞� + //璋冨害鎻愬崌鏈� + + //鑾峰彇鎻愬崌鏈哄懡浠� + List<LiftCommand> liftCommands = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), Utils.getLev(shuttleProtocol.getCurrentLocNo()), LiftCommandModeType.MOVE); + LiftCommand liftCommand = liftCommands.get(0); + + int deviceWrk = commonService.getWorkNo(8);//鐢熸垚鎻愬崌鏈鸿澶囧伐浣滃彿 + liftCommand.setTaskNo(deviceWrk);//鏇存崲闅忔満浠诲姟鍙� + + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); + + //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 + LiftAssignCommand assignCommand = new LiftAssignCommand(); + assignCommand.setCommands(commands); + assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); + assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); + + //涓嬪彂浠诲姟 + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + return false;//绛夊緟鎻愬崌鏈哄埌灏忚溅妤煎眰 + } + //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�*************** - List<NavigateNode> targetNodes = ForkLiftUtils.getLiftStaNodes(wrkMast.getStaNo()); + List<NavigateNode> targetNodes = liftThread.getLiftStaNodes(Utils.getLev(wrkMast.getLocNo())); if (targetNodes == null) { return false;//鏈幏鍙栧埌鑺傜偣 } @@ -1522,32 +3225,199 @@ assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� assignCommand.setAuto(true);//鑷姩妯″紡 - //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠� - List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + //鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护 + List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getLiftLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); if (commands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); - - //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� - navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo(), targetNodes, false); - return false;//璺緞瑙i攣澶辫触 + return false; } assignCommand.setCommands(commands); - wrkMast.setWrkSts(WrkStsType.MOVE_SITE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐� + wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 304.灏忚溅杩佸叆鎻愬崌鏈轰腑 wrkMast.setModiTime(now); - wrkMast.setSystemMsg("");//娓呯┖娑堟伅 if (wrkMastService.updateById(wrkMast)) { //涓嬪彂浠诲姟 shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); - notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); //瑙﹀彂閫氱煡 + notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_IN_LIFT); return false; } return false; } + return true; } + +// /** +// * 灏忚溅杩佺Щ-灏忚溅杩佸叆鎻愬崌鏈� +// * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false +// * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue +// */ +// private boolean shuttleMoveExecuteStepIntoLift(WrkMast wrkMast) { +// //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------// +// Date now = new Date(); +// +// //灏忚溅绉诲姩鍒版彁鍗囨満涓� 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 304.灏忚溅杩佸叆鎻愬崌鏈轰腑 +// if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_COMPLETE.sts) { +// //鑾峰彇鍥涘悜绌挎杞︾嚎绋� +// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); +// if (shuttleThread == null) { +// News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// return false; +// } +// +// ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); +// if (shuttleProtocol == null) { +// News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// return false; +// } +// +// LiftThread liftThread = null; +// LiftProtocol liftProtocol = null; +// if (wrkMast.getLiftNo() == null) { +// //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満 +// liftThread = LiftUtils.getRecentLift(shuttleProtocol.getCurrentLocNo()); +// if (liftThread == null) { +// News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂叉彁鍗囨満", shuttleProtocol.getShuttleNo(), shuttleProtocol.getCurrentLocNo()); +// return false;//娌℃湁鍙敤涓旂┖闂茬殑鎻愬崌鏈� +// } +// +// liftProtocol = liftThread.getStatus(); +// if (liftProtocol == null) { +// News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); +// return false; +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満) +// WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(liftProtocol.getLiftNo()); +// if (liftWrkMast != null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); +// return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� +// } +// +// wrkMast.setModiTime(now); +// wrkMast.setLiftNo(liftProtocol.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈� +// wrkMast.setSystemMsg("");//娓呯┖娑堟伅 +// wrkMastService.updateById(wrkMast); +// return false; +// }else { +// liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); +// if (liftThread == null) { +// News.info("{}鍙锋彁鍗囨満涓嶅瓨鍦�", wrkMast.getLiftNo()); +// return false; +// } +// +// liftProtocol = liftThread.getStatus(); +// if (liftProtocol == null) { +// News.info("{}鍙锋彁鍗囨満瀵硅薄涓嶅瓨鍦�", wrkMast.getLiftNo()); +// return false; +// } +// } +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 +// WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); +// if (liftWrkMast != null) { +// if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� +// News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� +// } +// } +// +// if (!liftThread.isIdle()) { +// News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); +// return false; +// } +// +// //灏忚溅澶勪簬绌洪棽鐘舵�� +// if (!shuttleThread.isIdle()) { +// News.info("{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false; +// } +// +// //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� +// if (liftProtocol.getHasCar()) { +// News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮湁灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); +// return false;//鎻愬崌鏈哄唴鏃犲皬杞� +// } +// +// //鍒ゆ柇鎻愬崌鏈烘ゼ灞� +// if (liftProtocol.getLev() != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { +// //鎻愬崌鏈轰笉鍦ㄥ皬杞︽ゼ灞� +// //璋冨害鎻愬崌鏈� +// +// //鑾峰彇鎻愬崌鏈哄懡浠� +// List<LiftCommand> liftCommands = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), Utils.getLev(shuttleProtocol.getCurrentLocNo()), LiftCommandModeType.MOVE); +// LiftCommand liftCommand = liftCommands.get(0); +// +// int deviceWrk = commonService.getWorkNo(8);//鐢熸垚鎻愬崌鏈鸿澶囧伐浣滃彿 +// liftCommand.setTaskNo(deviceWrk);//鏇存崲闅忔満浠诲姟鍙� +// +// ArrayList<LiftCommand> commands = new ArrayList<>(); +// commands.add(liftCommand); +// +// //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 +// LiftAssignCommand assignCommand = new LiftAssignCommand(); +// assignCommand.setCommands(commands); +// assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); +// assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); +// assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); +// +// //涓嬪彂浠诲姟 +// liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); +// return false;//绛夊緟鎻愬崌鏈哄埌灏忚溅妤煎眰 +// } +// +// if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { +// //璺ㄥ眰閿佸畾璺緞 +// //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�*************** +// List<NavigateNode> targetNodes = liftThread.getLiftStaNodes(Utils.getLev(wrkMast.getLocNo())); +// if (targetNodes == null) { +// return false;//鏈幏鍙栧埌鑺傜偣 +// } +// boolean checkPathIsAvailable = navigateUtils.checkPathIsAvailable(targetNodes, shuttleProtocol.getShuttleNo(), Utils.getLev(wrkMast.getLocNo())); +// if (!checkPathIsAvailable) { +// News.info("{}浠诲姟锛寋}灏忚溅锛岀洰鏍囩珯鐐硅矾寰勮鍗犵敤锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false;//妫�娴嬬洰鏍囩珯鐐硅矾寰勬槸鍚︽湭琚崰鐢� +// } +// //灏濊瘯閿佸畾鐩爣绔欒矾寰� +// boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo(), targetNodes, true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� +// if (!result2) { +// News.info("{}浠诲姟锛寋}灏忚溅锛岃矾寰勯攣瀹氬け璐ワ紝绂佹娲惧彂", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false;//璺緞閿佸畾澶辫触 +// } +// //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�*************** +// } +// +// ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); +// assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� +// assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟 +// assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� +// assignCommand.setAuto(true);//鑷姩妯″紡 +// +// //鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护 +// List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getLiftLocNo(Utils.getLev(shuttleProtocol.getCurrentLocNo())), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); +// if (commands == null) { +// News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); +// return false; +// } +// +// assignCommand.setCommands(commands); +// +// wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 304.灏忚溅杩佸叆鎻愬崌鏈轰腑 +// wrkMast.setModiTime(now); +// if (wrkMastService.updateById(wrkMast)) { +// //涓嬪彂浠诲姟 +// shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); +// //瑙﹀彂閫氱煡 +// notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_IN_LIFT); +// return false; +// } +// return false; +// } +// +// return true; +// } /** * 灏忚溅杩佺Щ-鎻愬崌鏈烘惉杩愪腑 @@ -1558,17 +3428,22 @@ //--------------------------------------鎻愬崌鏈烘惉杩愪腑-----------------------------------------// Date now = new Date(); - //鎻愬崌鏈烘惉杩愪腑 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑 - if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_COMPLETE.sts) { - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, wrkMast.getLiftNo()); - if (forkLiftThread == null) { + //鎻愬崌鏈烘惉杩愪腑 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑 + if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_COMPLETE.sts) { + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟锛屾湭缁戝畾鎻愬崌鏈猴紝鏁版嵁寮傚父锛岀姝㈡淳鍙�", wrkMast.getWrkNo()); return false; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { return false; } - if (!forkLiftThread.isIdle()) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + if (!liftThread.isIdle()) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); return false; } @@ -1581,38 +3456,50 @@ } } - //鑾峰彇婧愮珯 - ForkLiftStaProtocol sourceLiftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); - //鑾峰彇鐩爣绔� - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); - if (sourceLiftSta == null || liftSta == null) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀己灏戠珯鐐逛俊鎭紝绂佹娲惧彂", wrkMast.getWrkNo()); - return false;//缂哄皯绔欑偣淇℃伅 + //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞� + if (!liftProtocol.getHasCar()) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); + return false;//鎻愬崌鏈哄唴鏃犲皬杞� } - if (liftSta.getHasTray()) { - News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo()); - return false;//鏈夋墭鐩樿烦杩� + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); + if (shuttleThread == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + News.info("{}浠诲姟锛寋}鍙峰皬杞︼紝灏忚溅瀵硅薄涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; } //鑾峰彇鎻愬崌鏈哄懡浠� - List<ForkLiftCommand> liftCommands = forkLiftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev()); - ArrayList<ForkLiftCommand> commands = new ArrayList<>(); - commands.addAll(liftCommands); + List<LiftCommand> liftCommands = liftThread.getMoveCommand(wrkMast.getWrkNo(), Utils.getLev(wrkMast.getSourceLocNo()), Utils.getLev(wrkMast.getLocNo()), LiftCommandModeType.MOVE); + LiftCommand liftCommand = liftCommands.get(0); + + int deviceWrk = commonService.getWorkNo(8);//鐢熸垚鎻愬崌鏈鸿澶囧伐浣滃彿 + liftCommand.setTaskNo(deviceWrk);//鏇存崲闅忔満浠诲姟鍙� + + ArrayList<LiftCommand> commands = new ArrayList<>(); + commands.add(liftCommand); //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔 LiftAssignCommand assignCommand = new LiftAssignCommand(); assignCommand.setCommands(commands); assignCommand.setLiftNo(wrkMast.getLiftNo().shortValue()); assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); - assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue()); + assignCommand.setTaskMode(LiftCommandModeType.MOVE.id.shortValue()); - wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑 + wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑 wrkMast.setSystemMsg("");//娓呯┖娑堟伅 wrkMast.setModiTime(now); if (wrkMastService.updateById(wrkMast)) { //涓嬪彂浠诲姟 - forkLiftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); + //瑙﹀彂閫氱煡 + notifyUtils.notify(String.valueOf(SlaveType.Shuttle), liftProtocol.getLiftNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.LIFT_MOVE_SHUTTLE); } } return true; @@ -1629,6 +3516,20 @@ //鎻愬崌鏈烘惉杩愪腑 307.鎻愬崌鏈烘惉杩愬畬鎴� ==> 308.灏忚溅杩佸嚭鎻愬崌鏈轰腑 if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_RUN_COMPLETE.sts) { + if (wrkMast.getLiftNo() == null) { + News.info("{}浠诲姟锛屾湭缁戝畾鎻愬崌鏈猴紝鏁版嵁寮傚父锛岀姝㈡淳鍙�", wrkMast.getWrkNo()); + return false; + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + return false; + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); if (shuttleThread == null) { @@ -1645,19 +3546,62 @@ return false; } + if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.UPDATE_LOCATION.id);//鏇存柊鍧愭爣 + assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� + assignCommand.setAuto(true);//鑷姩妯″紡 + assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣� + assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅 + + //鏇存柊灏忚溅鍧愭爣 + ShuttleCommand command = shuttleThread.getUpdateLocationCommand(wrkMast.getWrkNo(), wrkMast.getLocNo()); + ArrayList<ShuttleCommand> commands = new ArrayList<>(); + commands.add(command); + + assignCommand.setCommands(commands); + shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + return false; + } + + //闇�瑕佸皢鍓嶄袱涓妭鐐逛綔涓虹櫧鍚嶅崟鑺傜偣浼犲叆 + List<NavigateNode> targetNodes = liftThread.getLiftStaNodes(Utils.getLev(wrkMast.getLocNo())); + + if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { + return false;//灏忚溅鏈埌杈剧洰鏍囧眰 + } + + //闇�瑕佸皢鍓嶄袱涓妭鐐逛綔涓虹櫧鍚嶅崟鑺傜偣浼犲叆 + if (targetNodes == null) { + return false;//鏈幏鍙栧埌鑺傜偣 + } + + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙� - assignCommand.setTaskMode(ShuttleTaskModeType.UPDATE_LOCATION.id);//鏇存柊鍧愭爣 + assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id); assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙� assignCommand.setAuto(true);//鑷姩妯″紡 assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣� assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅 - //鏇存柊灏忚溅鍧愭爣 - ShuttleCommand command = shuttleThread.getUpdateLocationCommand(wrkMast.getWrkNo(), wrkMast.getLocNo()); ArrayList<ShuttleCommand> commands = new ArrayList<>(); - commands.add(command); + int targetLev = Utils.getLev(wrkMast.getLocNo()); + //璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟 + ArrayList<int[]> whiteList = new ArrayList<>();//璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟 + for (NavigateNode node : targetNodes) { + whiteList.add(new int[]{node.getX(), node.getY()}); + } + //鑾峰彇灏忚溅鍑烘彁鍗囨満琛岃蛋鍛戒护 + List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(liftThread.getLiftLocNo(targetLev), liftThread.getLiftStandByLocNo(targetLev), NavigationMapType.NORMAL.id, whiteList, assignCommand, shuttleThread); + if (moveCommands == null) { + News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); + return false; + } + + commands.addAll(moveCommands); assignCommand.setCommands(commands); wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT.sts);//灏忚溅杩佸嚭鎻愬崌鏈轰腑 @@ -1667,6 +3611,8 @@ if (wrkMastService.updateById(wrkMast)) { //涓嬪彂浠诲姟 shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); + //瑙﹀彂閫氱煡 + notifyUtils.notify(String.valueOf(SlaveType.Shuttle), liftProtocol.getLiftNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING_OUT_LIFT); } } return true; @@ -1683,6 +3629,36 @@ //灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 310.灏忚溅绉诲姩涓� if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT_COMPLETE.sts) { + + List<NavigateNode> targetNodes = null; + if (wrkMast.getLiftNo() != null) { + //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟 + WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo()); + if (liftWrkMast != null) { + if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚� + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇� + } + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); + if (liftThread == null) { + News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満绾跨▼涓嶅瓨鍦紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo()); + return false; + } + + //灏忚溅鐩爣灏辨槸鎻愬崌鏈轰綅缃紝鐩存帴璁ゅ畾灏忚溅绉诲姩浠诲姟瀹屾垚 + if (liftThread.getLiftLocNo(Utils.getLev(wrkMast.getLocNo())).equals(wrkMast.getLocNo())) { + wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE.sts);//311.灏忚溅绉诲姩瀹屾垚 + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + wrkMast.setModiTime(now); + wrkMastService.updateById(wrkMast); + return false; + } + +// //闇�瑕佸皢鍓嶄袱涓妭鐐逛綔涓虹櫧鍚嶅崟鑺傜偣浼犲叆 +// targetNodes = liftThread.getLiftStaNodes(Utils.getLev(wrkMast.getLocNo())); + } //鑾峰彇鍥涘悜绌挎杞︾嚎绋� ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); @@ -1717,34 +3693,17 @@ assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣� assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅 - List<ShuttleCommand> commands = null; - //璺ㄦゼ灞傜Щ鍔ㄤ换鍔� - if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) { - if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) { - return false;//灏忚溅鏈埌杈剧洰鏍囧眰 - } + List<ShuttleCommand> commands = new ArrayList<>(); + List<ShuttleCommand> liftCommand = null; + Integer mapType = NavigationMapType.NORMAL.id; - //闇�瑕佸皢鍓嶄袱涓妭鐐逛綔涓虹櫧鍚嶅崟鑺傜偣浼犲叆 - List<NavigateNode> targetNodes = ForkLiftUtils.getLiftStaNodes(wrkMast.getStaNo()); - if (targetNodes == null) { - return false;//鏈幏鍙栧埌鑺傜偣 - } - - //璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟 - ArrayList<int[]> whiteList = new ArrayList<>();//璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟 - for (NavigateNode node : targetNodes) { - whiteList.add(new int[]{node.getX(), node.getY()}); - } - commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, whiteList, assignCommand, shuttleThread); - }else { - //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠� - commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); - } - - if (commands == null) { + List<ShuttleCommand> moveCommands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), mapType, assignCommand, shuttleThread); + if (moveCommands == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); return false;//璺緞璁$畻澶辫触 } + + commands.addAll(moveCommands); assignCommand.setCommands(commands); @@ -1759,65 +3718,6 @@ } } return true; - } - - //鑷姩鍒囨崲鍑哄叆搴撴ā寮� - public void autoSwitchForkLiftIOMode() { - for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) { - Integer liftNo = forkLiftSlave.getId(); - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - - //鑾峰彇鍏ュ簱浠诲姟 - List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .eq("lift_no", liftNo) - .in("wrk_sts" - , WrkStsType.NEW_INBOUND.sts - , WrkStsType.INBOUND_DEVICE_RUN.sts - , WrkStsType.INBOUND_LIFT_RUN.sts - , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts - , WrkStsType.INBOUND_SHUTTLE_RUN.sts - , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts - )); - - //鑾峰彇鍑哄簱浠诲姟 - List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() - .eq("lift_no", liftNo) - .in("wrk_sts" - , WrkStsType.NEW_OUTBOUND.sts - , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts - , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts - , WrkStsType.OUTBOUND_LIFT_RUN.sts - , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts - )); - - if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.NONE)) { - //鏈煡妯″紡 - if (!inWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); - } else if (!outWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); - }else { - forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); - } - } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { - //鍏ュ簱妯″紡 - if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); - } - } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { - //鍑哄簱妯″紡 - if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) { - forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); - } - } - } } } diff --git a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java index a378019..ec24df3 100644 --- a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java +++ b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java @@ -192,7 +192,12 @@ @Scheduled(cron = "0/1 * * * * ? ") @Transactional public void executeMove(){ - List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_MOVE.sts)); + List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("wrk_sts" + , WrkStsType.COMPLETE_MOVE.sts + , WrkStsType.COMPLETE_MOVE_TRANSPORT_LIFT.sts + , WrkStsType.COMPLETE_MOVE_TRANSPORT_LIFT_OUT.sts + )); if (wrkMasts.isEmpty()) { return; } diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java index bf3ea83..3c27181 100644 --- a/src/main/java/com/zy/asrs/utils/Utils.java +++ b/src/main/java/com/zy/asrs/utils/Utils.java @@ -4,6 +4,7 @@ import com.core.common.Arith; import com.core.common.Cools; import com.core.common.SpringUtils; +import com.core.exception.CoolException; import com.zy.asrs.entity.LocMast; import com.zy.asrs.entity.WrkMast; import com.zy.asrs.service.LocMastService; diff --git a/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java b/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java index 2234aaf..4f375ed 100644 --- a/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java +++ b/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java @@ -4,7 +4,7 @@ import com.core.common.R; import com.core.common.SpringUtils; import com.zy.asrs.controller.ConsoleController; -import com.zy.asrs.controller.ForkLiftController; +import com.zy.asrs.controller.LiftController; import com.zy.asrs.controller.ShuttleController; import com.zy.common.model.WebSocketMessage; import lombok.Data; @@ -71,7 +71,7 @@ @OnMessage public void onMessage(String message, Session session) throws IOException { ShuttleController shuttleController = SpringUtils.getBean(ShuttleController.class); - ForkLiftController liftController = SpringUtils.getBean(ForkLiftController.class); + LiftController liftController = SpringUtils.getBean(LiftController.class); ConsoleController consoleController = SpringUtils.getBean(ConsoleController.class); WebSocketMessage socketMessage = JSON.parseObject(message, WebSocketMessage.class); if (socketMessage.getUrl().equals("/shuttle/table/shuttle/state")) { diff --git a/src/main/java/com/zy/common/CodeBuilder.java b/src/main/java/com/zy/common/CodeBuilder.java index d8243bc..81775bf 100644 --- a/src/main/java/com/zy/common/CodeBuilder.java +++ b/src/main/java/com/zy/common/CodeBuilder.java @@ -12,10 +12,10 @@ CoolGenerator generator = new CoolGenerator(); // mysql generator.sqlOsType = SqlOsType.MYSQL; - generator.url="localhost:3306/shuttle_rcs"; + generator.url="localhost:3306/fyxc_shuttle"; generator.username="root"; generator.password="root"; - generator.table="asr_bas_shuttle_charge"; + generator.table="wcs_task_serial_no"; // sqlserver // generator.sqlOsType = SqlOsType.SQL_SERVER; // generator.url="127.0.0.1:1433;databasename=tzskasrs"; diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java index c9df23c..008db5a 100644 --- a/src/main/java/com/zy/common/service/CommonService.java +++ b/src/main/java/com/zy/common/service/CommonService.java @@ -124,18 +124,18 @@ throw new CoolException("婧愬簱浣嶄笉瀛樺湪"); } - if (!sourceLocMast.getLocSts().equals("F")) { - throw new CoolException("婧愬簱浣嶄笉澶勪簬鍦ㄥ簱鐘舵��"); - } +// if (!sourceLocMast.getLocSts().equals("F")) { +// throw new CoolException("婧愬簱浣嶄笉澶勪簬鍦ㄥ簱鐘舵��"); +// } LocMast locMast = locMastService.queryByLoc(param.getLocNo()); if (null == locMast) { throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦�"); } - if (!locMast.getLocSts().equals("O")) { - throw new CoolException("鐩爣搴撲綅涓嶅浜庣┖搴撶姸鎬�"); - } +// if (!locMast.getLocSts().equals("O")) { +// throw new CoolException("鐩爣搴撲綅涓嶅浜庣┖搴撶姸鎬�"); +// } // 鑾峰彇宸ヤ綔鍙� int workNo = getWorkNo(WrkIoType.LOC_MOVE.id); @@ -157,13 +157,13 @@ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); } - sourceLocMast.setLocSts("R"); - sourceLocMast.setModiTime(new Date()); - locMastService.updateById(sourceLocMast); - - locMast.setLocSts("S"); - locMast.setModiTime(new Date()); - locMastService.updateById(locMast); +// sourceLocMast.setLocSts("R"); +// sourceLocMast.setModiTime(new Date()); +// locMastService.updateById(sourceLocMast); +// +// locMast.setLocSts("S"); +// locMast.setModiTime(new Date()); +// locMastService.updateById(locMast); return true; } diff --git a/src/main/java/com/zy/common/utils/LiftUtils.java b/src/main/java/com/zy/common/utils/LiftUtils.java new file mode 100644 index 0000000..8f6c446 --- /dev/null +++ b/src/main/java/com/zy/common/utils/LiftUtils.java @@ -0,0 +1,255 @@ +package com.zy.common.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.core.common.SpringUtils; +import com.zy.asrs.utils.Utils; +import com.zy.common.model.NavigateNode; +import com.zy.common.model.enums.NavigationMapType; +import com.zy.core.cache.SlaveConnection; +import com.zy.core.enums.SlaveType; +import com.zy.core.model.ForkLiftSlave; +import com.zy.core.model.LiftSlave; +import com.zy.core.model.protocol.ForkLiftStaProtocol; +import com.zy.core.model.protocol.LiftProtocol; +import com.zy.core.model.protocol.LiftStaProtocol; +import com.zy.core.model.protocol.ShuttleProtocol; +import com.zy.core.properties.SlaveProperties; +import com.zy.core.thread.ForkLiftThread; +import com.zy.core.thread.LiftThread; +import com.zy.core.thread.ShuttleThread; +import com.zy.core.thread.impl.NyLiftThread; +import com.zy.system.entity.Config; +import com.zy.system.service.ConfigService; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * 鎻愬崌鏈哄伐鍏风被 + */ +public class LiftUtils { + + //鑾峰彇鎻愬崌鏈虹珯鐐� + public static LiftStaProtocol getLiftStaByStaNo(Integer staNo) { + SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); + for (LiftSlave liftSlave : slaveProperties.getLift()) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); + if (liftThread == null) { + return null; + } + + for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { + if (liftStaProtocol.getStaNo().equals(staNo)) { + return liftStaProtocol; + } + } + } + + return null; + } + + //鑾峰彇鎻愬崌鏈虹珯鐐� + public static LiftStaProtocol getLiftStaByLev(Integer liftNo, Integer lev) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { + return null; + } + + for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { + if (liftStaProtocol.getLev().equals(lev)) { + return liftStaProtocol; + } + } + + return null; + } + + //鑾峰彇鎻愬崌鏈鸿緭閫佺珯鍙婂叾鍓嶄竴绔欒妭鐐� + public static List<NavigateNode> getLiftStaNodes(Integer staNo) { + List<NavigateNode> targetNodes = new ArrayList<>(); + //鑾峰彇鐩爣绔� + LiftStaProtocol targetLiftSta = LiftUtils.getLiftStaByStaNo(staNo); + if (targetLiftSta == null) { + return null;//鎵句笉鍒扮珯鐐� + } + NavigateNode targetNode = NavigatePositionConvert.locNoToNode(targetLiftSta.getLocNo());//鐩爣鑺傜偣 + String targetLastLocNo = Utils.getLocNo(Utils.getRow(targetLiftSta.getLocNo()) - 1, Utils.getBay(targetLiftSta.getLocNo()), Utils.getLev(targetLiftSta.getLocNo()));//鐩爣鑺傜偣鍓嶄竴绔� + NavigateNode targetLastNode = NavigatePositionConvert.locNoToNode(targetLastLocNo);//鐩爣鑺傜偣鍓嶄竴绔� + targetNodes.add(targetNode); + targetNodes.add(targetLastNode); + + return targetNodes; + } + + //閫氳繃杈撻�佺嚎绔欏彿鑾峰彇瀵瑰簲鎻愬崌鏈哄彿 + public static Integer getConveyorBindLiftNo(Integer staNo) { + ConfigService configService = SpringUtils.getBean(ConfigService.class); + if (configService == null) { + return null; + } + + Config conveyorLiftBindConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "conveyorLiftBind")); + if(conveyorLiftBindConfig == null) { + return null; + } + + List<JSONObject> list = JSON.parseArray(conveyorLiftBindConfig.getValue(), JSONObject.class); + if (list.isEmpty()) { + return null; + } + + for (JSONObject data : list) { + if(data.getInteger("staNo").equals(staNo)) { + return data.getInteger("liftNo"); + } + } + + return null; + } + + //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿嚭搴� + //鏌ヨ鏄惁鏈夊嚭搴撴潈闄� + public static boolean queryOutMission(Integer staNo) { + ConfigService configService = SpringUtils.getBean(ConfigService.class); + if (configService == null) { + return false; + } + + Config queryOutMissionPathEnableConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "queryOutMissionPathEnable")); + if (queryOutMissionPathEnableConfig != null) { + String queryOutMissionPathEnable = queryOutMissionPathEnableConfig.getValue(); + if (!queryOutMissionPathEnable.equals("Y")) { + return true;//鍏抽棴鏌ヨ鍑哄簱鏉冮檺鍔熻兘 + } + } + + Config superSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "superSystemUri")); + if (superSystemUriConfig == null) { + return false; + } + String superSystemUri = superSystemUriConfig.getValue(); + + Config queryOutMissionPathConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "queryOutMissionPath")); + if (queryOutMissionPathConfig == null) { + return false; + } + String missionPath = queryOutMissionPathConfig.getValue(); + + try { + HashMap<String, Object> data = new HashMap<>(); + data.put("staNo", staNo); + + String response = new HttpHandler.Builder() + .setUri(superSystemUri) + .setPath(missionPath) + .setJson(JSON.toJSONString(data)) + .build() + .doPost(); + if (response.equals("ok")) { + return true;//鏈夊嚭搴撴潈闄� + } + }catch (Exception e){ + e.printStackTrace(); + } + return false; + } + + //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿叆搴� + //鏌ヨ鏄惁鏈夊叆搴撴潈闄� + public static boolean queryInMission(Integer sourceStaNo, Integer liftNo, String superTaskNo) { + ConfigService configService = SpringUtils.getBean(ConfigService.class); + if (configService == null) { + return false; + } + + Config queryInMissionPathEnableConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "queryInMissionPathEnable")); + if (queryInMissionPathEnableConfig != null) { + String queryInMissionPathEnable = queryInMissionPathEnableConfig.getValue(); + if (!queryInMissionPathEnable.equals("Y")) { + return true;//鍏抽棴鏌ヨ鍏ュ簱鏉冮檺鍔熻兘 + } + } + + Config superSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "superSystemUri")); + if (superSystemUriConfig == null) { + return false; + } + String superSystemUri = superSystemUriConfig.getValue(); + + Config queryInMissionPathConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "queryInMissionPath")); + if (queryInMissionPathConfig == null) { + return false; + } + String missionPath = queryInMissionPathConfig.getValue(); + + try { + HashMap<String, Object> data = new HashMap<>(); + data.put("staNo", sourceStaNo); + data.put("liftNo", liftNo); + data.put("superTaskNo", superTaskNo); + + String response = new HttpHandler.Builder() + .setUri(superSystemUri) + .setPath(missionPath) + .setJson(JSON.toJSONString(data)) + .build() + .doPost(); + if (response.equals("ok")) { + return true;//鏈夊叆搴撴潈闄� + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + /** + * 鑾峰彇鍧愭爣鏈�杩戜笖姝e父鐨勬彁鍗囨満 + */ + public static LiftThread getRecentLift(String locNo) { + SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); + NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class); + + String currentLocNo = locNo; + Integer recentAllDistance = 9999999; + LiftThread recentLift = null;//鏈�杩戠珯鐐� + for (LiftSlave slave : slaveProperties.getLift()) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + continue; + } + + if (!liftThread.isDeviceIdle()) { + continue; + } + + //鎼滅储璺濈灏忚溅鏈�杩戠殑鎻愬崌鏈� + String liftLocNo = liftThread.getLiftLocNo(Utils.getLev(locNo)); + if (locNo.equals(liftLocNo)) { + return liftThread; + } + + //鐩爣鍦扮偣璺濈 + List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, liftLocNo, NavigationMapType.NORMAL.id, null, null);//浣跨敤姝e父閫氶亾鍦板浘 + if (currentShuttlePath == null) { + continue; + } + Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� + if (currentAllDistance < recentAllDistance) { + //濡傛灉褰撳墠妤煎眰鐨勮矾寰勬洿灏忥紝鍒欐洿鏂版渶杩戠珯鐐� + recentLift = liftThread; + recentAllDistance = currentAllDistance; + } + } + + return recentLift; + } + +} diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java index d19f34b..94b016c 100644 --- a/src/main/java/com/zy/common/utils/NavigateMapData.java +++ b/src/main/java/com/zy/common/utils/NavigateMapData.java @@ -132,8 +132,8 @@ //鍔犺浇杞﹁締 lists = loadShuttle(lists, shuttlePoints); - //鍔犺浇璐у弶鎻愬崌鏈虹偣浣� - lists = loadForkLift(lists, mapType, lev); +// //鍔犺浇璐у弶鎻愬崌鏈虹偣浣� +// lists = loadForkLift(lists, mapType, lev); //鍔犺浇鐧藉悕鍗曡妭鐐� lists = loadWhite(lists, lev, whitePoints); diff --git a/src/main/java/com/zy/core/MainProcess.java b/src/main/java/com/zy/core/MainProcess.java index 1f0250b..c500a2c 100644 --- a/src/main/java/com/zy/core/MainProcess.java +++ b/src/main/java/com/zy/core/MainProcess.java @@ -51,10 +51,14 @@ mainService.shuttleFinished(); //鎵ц绉诲簱浠诲姟 mainService.shuttleLocMoveExecute(); - //璐у弶鎻愬崌鏈轰换鍔� - mainService.forkLiftIoExecute(); - //璐у弶鎻愬崌鏈轰换鍔″畬鎴� - mainService.forkLiftFinished(); +// //璐у弶鎻愬崌鏈轰换鍔� +// mainService.forkLiftIoExecute(); +// //璐у弶鎻愬崌鏈轰换鍔″畬鎴� +// mainService.forkLiftFinished(); +// //鎻愬崌鏈轰换鍔� +// mainService.liftIoExecute(); + //鎻愬崌鏈轰换鍔″畬鎴� + mainService.liftFinished(); //鎵ц灏忚溅绉诲姩浠诲姟 mainService.shuttleMoveExecute(); // 寮傚父淇℃伅璁板綍 @@ -62,9 +66,6 @@ // 绌挎杞� ===>> 灏忚溅鐢甸噺妫�娴嬪厖鐢� mainService.loopShuttleCharge(); mainService.executeShuttleCharge(); - - //鑷姩鍒囨崲鍑哄叆搴撴ā寮� - mainService.autoSwitchForkLiftIOMode(); // 闂撮殧 Thread.sleep(200); diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java index c5c91c0..44b5464 100644 --- a/src/main/java/com/zy/core/ServerBootstrap.java +++ b/src/main/java/com/zy/core/ServerBootstrap.java @@ -8,10 +8,7 @@ import com.zy.core.model.*; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.*; -import com.zy.core.thread.impl.LfdZyForkLiftMasterThread; -import com.zy.core.thread.impl.LfdZyForkLiftSlaveThread; -import com.zy.core.thread.impl.NyShuttleThread; -import com.zy.core.thread.impl.ZyForkLiftThread; +import com.zy.core.thread.impl.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; @@ -54,6 +51,10 @@ for (Slave forkLift : slaveProperties.getForkLift()) { MessageQueue.init(SlaveType.ForkLift, forkLift); } + // 鍒濆鍖栨彁鍗囨満mq + for (Slave forkLift : slaveProperties.getForkLift()) { + MessageQueue.init(SlaveType.Lift, forkLift); + } // 鍒濆鍖栧洓鍚戠┛姊溅mq for (Slave shuttle : slaveProperties.getShuttle()) { MessageQueue.init(SlaveType.Shuttle, shuttle); @@ -91,6 +92,20 @@ SlaveConnection.put(SlaveType.ForkLiftMaster, forkLiftSlave.getId(), thread); } + // 鍒濆鍖栨彁鍗囨満 + for (LiftSlave slave : slaveProperties.getLift()) { + News.info("鍒濆鍖栨彁鍗囨満........................................................"); + ThreadHandler thread = null; + if (slave.getThreadImpl().equals("NyLiftThread")) { + thread = new NyLiftThread(slave, redisUtil); + } else { + throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�"); + } + + new Thread(thread).start(); + SlaveConnection.put(SlaveType.Lift, slave.getId(), thread); + } + // 鍒濆鍖栧洓鍚戠┛姊溅 for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) { News.info("鍒濆鍖栧洓鍚戠┛姊溅......................................................"); diff --git a/src/main/java/com/zy/core/action/ForkLiftAction.java b/src/main/java/com/zy/core/action/ForkLiftAction.java index b6e7c0f..2260be0 100644 --- a/src/main/java/com/zy/core/action/ForkLiftAction.java +++ b/src/main/java/com/zy/core/action/ForkLiftAction.java @@ -34,99 +34,99 @@ private BasLiftOptService basLiftOptService; public synchronized boolean assignWork(Integer liftNo, LiftAssignCommand assignCommand) { - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - return false; - } - - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return false; - } - - LiftRedisCommand redisCommand = new LiftRedisCommand(); - redisCommand.setLiftNo(assignCommand.getLiftNo());//鎻愬崌鏈哄彿 - redisCommand.setWrkNo(assignCommand.getTaskNo());//宸ヤ綔鍙� - redisCommand.setCommandStep(0);//鍛戒护鎵ц姝ュ簭 - redisCommand.setAssignCommand(assignCommand);//鍛戒护 - //浠诲姟鏁版嵁淇濆瓨鍒皉edis - if (redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) { - forkLiftThread.setSyncTaskNo(assignCommand.getTaskNo().intValue()); - return true; - } +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// return false; +// } +// +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return false; +// } +// +// LiftRedisCommand redisCommand = new LiftRedisCommand(); +// redisCommand.setLiftNo(assignCommand.getLiftNo());//鎻愬崌鏈哄彿 +// redisCommand.setWrkNo(assignCommand.getTaskNo());//宸ヤ綔鍙� +// redisCommand.setCommandStep(0);//鍛戒护鎵ц姝ュ簭 +// redisCommand.setAssignCommand(assignCommand);//鍛戒护 +// //浠诲姟鏁版嵁淇濆瓨鍒皉edis +// if (redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) { +// forkLiftThread.setSyncTaskNo(assignCommand.getTaskNo().intValue()); +// return true; +// } return false; } public synchronized boolean executeWork(Integer liftNo, Integer taskNo) { - Object obj = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + taskNo); - if (obj == null) { - return false; - } - -// WrkMast wrkMast = wrkMastService.selectByWorkNo(taskNo); -// if (wrkMast == null) { +// Object obj = redisUtil.get(RedisKeyType.FORK_LIFT_WORK_FLAG.key + taskNo); +// if (obj == null) { // return false; // } - - LiftRedisCommand redisCommand = JSON.parseObject(obj.toString(), LiftRedisCommand.class); - if (redisCommand == null) { - return false; - } - - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { - return false; - } - - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - return false; - } - - List<ForkLiftCommand> commands = redisCommand.getAssignCommand().getCommands(); - if (commands.isEmpty()) { - return false; - } - - LiftAssignCommand assignCommand = redisCommand.getAssignCommand(); - int commandStep = redisCommand.getCommandStep(); - - if (commandStep == 0) { - //鍙栧嚭鍛戒护 - ForkLiftCommand command = commands.get(commandStep); - - //鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂� - if (!forkLiftThread.isDeviceIdle()) { - return false; - } - - // 涓嬪彂鍛戒护 - CommandResponse response = write(command, liftNo); - - //淇濆瓨鍛戒护鏃ュ織 - BasLiftOpt basLiftOpt = new BasLiftOpt(); - basLiftOpt.setWrkNo(taskNo); - basLiftOpt.setLiftNo(liftNo); - basLiftOpt.setCommand(JSON.toJSONString(command)); - basLiftOpt.setSystemStatus(JSON.toJSONString(forkLiftProtocol)); - basLiftOpt.setDeviceWrk(String.valueOf(command.getTaskNo())); - basLiftOpt.setSendTime(new Date());//鎸囦护涓嬪彂鏃堕棿 - //淇濆瓨鍛戒护娴佹按 - basLiftOptService.insert(basLiftOpt); - - if (!response.getResult()) { - News.error("璐у弶鎻愬崌鏈哄懡浠や笅鍙戝け璐ワ紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); - return false; - } else { - News.info("璐у弶鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); - } - - commandStep++; - //鏇存柊redis鏁版嵁 - redisCommand.setCommandStep(commandStep); - // 鏇存柊redis鏁版嵁 - redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + taskNo, JSON.toJSONString(redisCommand)); - } +// +//// WrkMast wrkMast = wrkMastService.selectByWorkNo(taskNo); +//// if (wrkMast == null) { +//// return false; +//// } +// +// LiftRedisCommand redisCommand = JSON.parseObject(obj.toString(), LiftRedisCommand.class); +// if (redisCommand == null) { +// return false; +// } +// +// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); +// if (forkLiftThread == null) { +// return false; +// } +// +// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); +// if (forkLiftProtocol == null) { +// return false; +// } +// +// List<ForkLiftCommand> commands = redisCommand.getAssignCommand().getCommands(); +// if (commands.isEmpty()) { +// return false; +// } +// +// LiftAssignCommand assignCommand = redisCommand.getAssignCommand(); +// int commandStep = redisCommand.getCommandStep(); +// +// if (commandStep == 0) { +// //鍙栧嚭鍛戒护 +// ForkLiftCommand command = commands.get(commandStep); +// +// //鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂� +// if (!forkLiftThread.isDeviceIdle()) { +// return false; +// } +// +// // 涓嬪彂鍛戒护 +// CommandResponse response = write(command, liftNo); +// +// //淇濆瓨鍛戒护鏃ュ織 +// BasLiftOpt basLiftOpt = new BasLiftOpt(); +// basLiftOpt.setWrkNo(taskNo); +// basLiftOpt.setLiftNo(liftNo); +// basLiftOpt.setCommand(JSON.toJSONString(command)); +// basLiftOpt.setSystemStatus(JSON.toJSONString(forkLiftProtocol)); +// basLiftOpt.setDeviceWrk(String.valueOf(command.getTaskNo())); +// basLiftOpt.setSendTime(new Date());//鎸囦护涓嬪彂鏃堕棿 +// //淇濆瓨鍛戒护娴佹按 +// basLiftOptService.insert(basLiftOpt); +// +// if (!response.getResult()) { +// News.error("璐у弶鎻愬崌鏈哄懡浠や笅鍙戝け璐ワ紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); +// return false; +// } else { +// News.info("璐у弶鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); +// } +// +// commandStep++; +// //鏇存柊redis鏁版嵁 +// redisCommand.setCommandStep(commandStep); +// // 鏇存柊redis鏁版嵁 +// redisUtil.set(RedisKeyType.FORK_LIFT_WORK_FLAG.key + taskNo, JSON.toJSONString(redisCommand)); +// } return true; } diff --git a/src/main/java/com/zy/core/action/LiftAction.java b/src/main/java/com/zy/core/action/LiftAction.java new file mode 100644 index 0000000..e0b7d2a --- /dev/null +++ b/src/main/java/com/zy/core/action/LiftAction.java @@ -0,0 +1,207 @@ +package com.zy.core.action; + +import com.alibaba.fastjson.JSON; +import com.zy.asrs.entity.BasLiftOpt; +import com.zy.asrs.service.BasLiftOptService; +import com.zy.asrs.service.WrkMastService; +import com.zy.common.utils.RedisUtil; +import com.zy.core.News; +import com.zy.core.cache.SlaveConnection; +import com.zy.core.enums.*; +import com.zy.core.model.CommandResponse; +import com.zy.core.model.command.LiftAssignCommand; +import com.zy.core.model.command.LiftCommand; +import com.zy.core.model.command.LiftRedisCommand; +import com.zy.core.model.protocol.LiftProtocol; +import com.zy.core.thread.LiftThread; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.List; + +@Component +public class LiftAction { + + @Autowired + private RedisUtil redisUtil; + @Autowired + private WrkMastService wrkMastService; + @Autowired + private BasLiftOptService basLiftOptService; + + public synchronized boolean assignWork(Integer liftNo, LiftAssignCommand assignCommand) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + + LiftRedisCommand redisCommand = new LiftRedisCommand(); + redisCommand.setLiftNo(assignCommand.getLiftNo());//鎻愬崌鏈哄彿 + redisCommand.setWrkNo(assignCommand.getTaskNo());//宸ヤ綔鍙� + redisCommand.setCommandStep(0);//鍛戒护鎵ц姝ュ簭 + redisCommand.setAssignCommand(assignCommand);//鍛戒护 + //浠诲姟鏁版嵁淇濆瓨鍒皉edis + if (redisUtil.set(RedisKeyType.LIFT_WORK_FLAG.key + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) { + liftThread.setSyncTaskNo(assignCommand.getTaskNo().intValue()); + return true; + } + return false; + } + + public synchronized boolean executeWork(Integer liftNo, Integer taskNo) { + Object obj = redisUtil.get(RedisKeyType.LIFT_WORK_FLAG.key + taskNo); + if (obj == null) { + return false; + } + +// WrkMast wrkMast = wrkMastService.selectByWorkNo(taskNo); +// if (wrkMast == null) { +// return false; +// } + + LiftRedisCommand redisCommand = JSON.parseObject(obj.toString(), LiftRedisCommand.class); + if (redisCommand == null) { + return false; + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { + return false; + } + + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + + List<LiftCommand> commands = redisCommand.getAssignCommand().getCommands(); + if (commands.isEmpty()) { + return false; + } + + LiftAssignCommand assignCommand = redisCommand.getAssignCommand(); + int commandStep = redisCommand.getCommandStep(); + + if (commandStep == 0) { + //鍙栧嚭鍛戒护 + LiftCommand command = commands.get(commandStep); + + //鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂� + if (!liftThread.isDeviceIdle()) { + return false; + } + + // 涓嬪彂鍛戒护 + CommandResponse response = write(command, liftNo); + + //淇濆瓨鍛戒护鏃ュ織 + BasLiftOpt basLiftOpt = new BasLiftOpt(); + basLiftOpt.setWrkNo(taskNo); + basLiftOpt.setLiftNo(liftNo); + basLiftOpt.setCommand(JSON.toJSONString(command)); + basLiftOpt.setSystemStatus(JSON.toJSONString(liftProtocol)); + basLiftOpt.setDeviceWrk(String.valueOf(command.getTaskNo())); + basLiftOpt.setSendTime(new Date());//鎸囦护涓嬪彂鏃堕棿 + //淇濆瓨鍛戒护娴佹按 + basLiftOptService.insert(basLiftOpt); + + if (!response.getResult()) { + News.error("鎻愬崌鏈哄懡浠や笅鍙戝け璐ワ紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); + return false; + } else { + News.info("鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); + } + + commandStep++; + //鏇存柊redis鏁版嵁 + redisCommand.setCommandStep(commandStep); + // 鏇存柊redis鏁版嵁 + redisUtil.set(RedisKeyType.LIFT_WORK_FLAG.key + taskNo, JSON.toJSONString(redisCommand)); + }else { + LiftCommand command = commands.get(commandStep - 1); + if (command.getMode() == LiftCommandModeType.MOVE.id) { + //鎻愬崌鏈哄崌闄� + Integer target = command.getTargetLev(); + if (liftProtocol.getLev() == target) { + command.setComplete(true); + } + } else if (command.getMode() == LiftCommandModeType.PALLET_IN.id) { +// //鎵樼洏鍏� +// Integer target = liftDispatcher.getLiftLevLogic(liftThread.getDevice().getId().intValue(), command.getTargetLev()); +// if (liftProtocol.getLev() == target) { +// command.setComplete(true); +// } +// +// //鍒ゆ柇鎻愬崌鏈烘墭鐩樻槸鍚﹀瓨鍦� +// if (!liftProtocol.getHasTray()) { +// return false; +// } + + } else if (command.getMode() == LiftCommandModeType.PALLET_OUT.id) { +// //鎵樼洏鍑� +// Integer target = liftDispatcher.getLiftLevLogic(liftThread.getDevice().getId().intValue(), command.getTargetLev()); +// if (liftProtocol.getLev() == target) { +// command.setComplete(true); +// } +// +// //鍒ゆ柇鎻愬崌鏈烘墭鐩樻槸鍚﹀瓨鍦� +// if (liftProtocol.getHasTray()) { +// return false; +// } + } else if (command.getMode() == LiftCommandModeType.RESET.id) { + //澶嶄綅 + command.setComplete(true); + } + + // 鏇存柊redis鏁版嵁 + redisUtil.set(RedisKeyType.LIFT_WORK_FLAG.key + taskNo, JSON.toJSONString(redisCommand)); + + if (!command.getComplete()) { + return false; + } + + //鍒ゆ柇鏄惁涓烘渶鍚庝竴鏉″懡浠や笖鍛戒护鎵ц瀹屾垚锛屾姏鍑虹瓑寰呯‘璁ょ姸鎬� + LiftCommand endCommand = commands.get(commands.size() - 1); + if (endCommand.getComplete()) { + News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", liftProtocol.getLiftNo(), JSON.toJSON(commands)); + + //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting + liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING); + redisUtil.del(RedisKeyType.LIFT_WORK_FLAG.key + taskNo); + return false;//绂佹鍐嶄笅鍙戝懡浠� + } + } + + return true; + } + + private synchronized CommandResponse write(LiftCommand command, Integer liftNo) { + CommandResponse response = new CommandResponse(false); + if (null == command) { + News.error("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�"); + response.setMessage("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�"); + return response; + } + + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { + return response; + } + + if (command.getMode().intValue() == LiftCommandModeType.MOVE.id) { + response = liftThread.move(command); + } else if (command.getMode().intValue() == LiftCommandModeType.PALLET_IN.id) { + response = liftThread.palletInOut(command); + } else if (command.getMode().intValue() == LiftCommandModeType.PALLET_OUT.id) { + response = liftThread.palletInOut(command); + } + return response; + } + +} diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java index f9fffa0..61ed0ff 100644 --- a/src/main/java/com/zy/core/action/ShuttleAction.java +++ b/src/main/java/com/zy/core/action/ShuttleAction.java @@ -219,8 +219,14 @@ // 绯荤粺浠诲姟 if (assignCommand.getAuto()) { if (!assignCommand.getCharge()) { - //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting - shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WAITING); + if (command.getMode() == ShuttleCommandModeType.UPDATE_LOCATION.id) { + //鏇存柊鍧愭爣浠诲姟鏃犻渶鎶涘嚭绛夊緟纭 + shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); + shuttleThread.setSyncTaskNo(0); + }else { + //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting + shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WAITING); + } }else { shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); } diff --git a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java index 6f10725..3c7c31d 100644 --- a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java +++ b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java @@ -15,6 +15,7 @@ import com.zy.common.model.enums.NavigationMapType; import com.zy.common.service.CommonService; import com.zy.common.utils.ForkLiftUtils; +import com.zy.common.utils.LiftUtils; import com.zy.common.utils.NavigateUtils; import com.zy.core.News; import com.zy.core.cache.SlaveConnection; @@ -22,10 +23,12 @@ import com.zy.core.enums.WrkIoType; import com.zy.core.enums.WrkStsType; import com.zy.core.model.ForkLiftSlave; +import com.zy.core.model.LiftSlave; import com.zy.core.model.ShuttleSlave; import com.zy.core.model.protocol.*; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.ForkLiftThread; +import com.zy.core.thread.LiftThread; import com.zy.core.thread.ShuttleThread; import com.zy.system.entity.Config; import com.zy.system.service.ConfigService; @@ -53,6 +56,13 @@ private ConfigService configService; @Autowired private BasShuttleService basShuttleService; + + /** + * 璋冨害杞﹁締-璋冨害鎸囧畾绌挎杞� + */ + public boolean dispatchShuttle(Integer wrkNo, String sourceLocNo, String locNo, Integer shuttleNo, String flag) { + return shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false); + } /** * 璋冨害杞﹁締-璋冨害鎸囧畾绌挎杞� @@ -203,6 +213,14 @@ */ @Transactional public boolean shuttleMoveGenerate(Integer wrkNo, String locNo, Integer shuttleNo) { + return shuttleMoveGenerate(wrkNo, null, locNo, shuttleNo, null, false); + } + + /** + * 灏忚溅杩佺Щ浠诲姟鐢熸垚 + */ + @Transactional + public boolean shuttleMoveGenerate(Integer wrkNo, String sourceLocNo, String locNo, Integer shuttleNo, String flag, boolean disableCheck) { Date now = new Date(); //鑾峰彇鍥涘悜绌挎杞︾嚎绋� ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); @@ -224,7 +242,7 @@ //鍒ゆ柇绌挎杞︽槸鍚﹀瓨鍦ㄦ湭瀹屾垚鐨勫皬杞︾Щ搴撲换鍔� WrkMast hasMoveWorking = wrkMastService.selectShuttleHasMoveWorking(shuttleNo); - if (hasMoveWorking != null) {//灏忚溅瀛樺湪绉诲簱浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔� + if (hasMoveWorking != null && !disableCheck) {//灏忚溅瀛樺湪绉诲簱浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔� News.info("{}鍙峰皬杞︼紝瀛樺湪绉诲姩浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo); return false; } @@ -234,11 +252,11 @@ //鍒ゆ柇鏄惁鏈夊叾浠栦换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅 WrkMast wrkMast2 = wrkMastService.selectShuttleWorking(shuttleNo); - if (wrkMast2 != null) {//灏忚溅瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍚庡啀鐢熸垚鏂扮殑浠诲姟 + if (wrkMast2 != null && !disableCheck) {//灏忚溅瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍚庡啀鐢熸垚鏂扮殑浠诲姟 if (mainWrkMast == null) { News.info("{}鍙峰皬杞︼紝瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo); return false; - }else { + } else { if (!mainWrkMast.getShuttleNo().equals(shuttleNo)) { News.info("{}鍙峰皬杞︼紝瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo); return false; @@ -246,41 +264,24 @@ } } - Integer sourceStaNo = null;//灏忚溅鎹㈠眰婧愮珯鐐� - Integer staNo = null;//灏忚溅鎹㈠眰鐩爣绔欑偣 - if (Utils.getLev(locNo) != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { - //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庝笉鍚屼竴妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴� - //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐� - ForkLiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo)); - if (liftSta == null) { - News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂茶緭閫佺珯鐐�", shuttleNo, locNo); - return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐� - } - sourceStaNo = liftSta.getStaNo();//婧愮珯鐐� - - ForkLiftStaProtocol targetLiftSta = ForkLiftUtils.getLiftStaByLev(liftSta.getLiftNo(), Utils.getLev(locNo)); - if (targetLiftSta == null) { - News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夌洰鏍囩珯鐐�", shuttleNo, locNo); - return false;//娌℃湁鎵惧埌鐩爣绔欑偣 - } - //鐩爣绔欑偣 - staNo = targetLiftSta.getStaNo();//鐩爣绔� + String currentLocNo = shuttleProtocol.getCurrentLocNo(); + if (sourceLocNo != null) { + currentLocNo = sourceLocNo; } // 鑾峰彇宸ヤ綔鍙� int workNo = commonService.getWorkNo(WrkIoType.SHUTTLE_MOVE.id); // 淇濆瓨宸ヤ綔妗� WrkMast wrkMast = new WrkMast(); + wrkMast.setMk(flag); wrkMast.setWrkNo(workNo); wrkMast.setIoTime(now); wrkMast.setWrkSts(WrkStsType.NEW_MOVE.sts); // 宸ヤ綔鐘舵�侊細301.鐢熸垚杩佺Щ浠诲姟 wrkMast.setIoType(WrkIoType.SHUTTLE_MOVE.id); // 鍏ュ嚭搴撶姸鎬侊細 200.灏忚溅杩佺Щ wrkMast.setIoPri(800D); wrkMast.setShuttleNo(shuttleNo);//绌挎杞﹀彿 - wrkMast.setSourceLocNo(shuttleProtocol.getCurrentLocNo()); // 婧愬簱浣� => 灏忚溅褰撳墠搴撲綅鍙� + wrkMast.setSourceLocNo(currentLocNo); // 婧愬簱浣� wrkMast.setLocNo(locNo); // 鐩爣搴撲綅 - wrkMast.setSourceStaNo(sourceStaNo);//婧愮珯 - wrkMast.setStaNo(staNo);//鐩爣绔� wrkMast.setAppeTime(now); wrkMast.setModiTime(now); boolean res = wrkMastService.insert(wrkMast); @@ -395,94 +396,7 @@ return levCount < Integer.parseInt(config.getValue()); } - /** - * 鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐� - */ - public ForkLiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) { - //鑾峰彇鍥涘悜绌挎杞︾嚎绋� - ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); - if (shuttleThread == null) { - return null; - } - ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); - if (shuttleProtocol == null) { - return null; - } - //鑾峰彇灏忚溅鍚屼竴妤煎眰鐨勭珯鐐� - ArrayList<ForkLiftStaProtocol> list = new ArrayList<>(); - int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅妤煎眰 - for (ForkLiftSlave slave : slaveProperties.getForkLift()) { - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); - if (forkLiftThread == null) { - continue; - } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { - continue; - } - if (!forkLiftThread.isIdle()) { - continue; - } - - ForkLiftStaProtocol forkLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(slave.getId(), lev); - if (forkLiftStaProtocol == null) { - continue; - } - - //鍒ゆ柇褰撳墠灞傛槸鍚︽棤鎵樼洏 - if (forkLiftStaProtocol.getHasTray()) { - continue; - } - - if (forkLiftStaProtocol.getHasCar()) { - continue; - } - - //鍒ゆ柇鐩爣妤煎眰绔欑偣鏄惁鏃犳墭鐩� - ForkLiftStaProtocol targetLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(slave.getId(), targetLev); - if (targetLiftStaProtocol == null) { - continue; - } - - if (targetLiftStaProtocol.getHasTray()) { - continue;//鏈夋墭鐩樿烦杩� - } - - if (targetLiftStaProtocol.getHasCar()) { - continue; - } - - list.add(forkLiftStaProtocol); - } - - if (list.isEmpty()) { - return null; - } - - String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅浣嶇疆 - Integer recentAllDistance = 9999999; - ForkLiftStaProtocol recentSta = null;//鏈�杩戠珯鐐� - //鎼滅储璺濈灏忚溅鏈�杩戠殑绔欑偣 - for (ForkLiftStaProtocol forkLiftStaProtocol : list) { - Integer staNo = forkLiftStaProtocol.getStaNo();//绔欑偣鍙� - String locNo = forkLiftStaProtocol.getLocNo();//绔欑偣搴撲綅鍙� - - //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈 - List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//浣跨敤姝e父閫氶亾鍦板浘 - if (currentShuttlePath == null) { - continue; - } - Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� - if (currentAllDistance < recentAllDistance) { - //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠珯鐐� - recentSta = forkLiftStaProtocol; - recentAllDistance = currentAllDistance; - } - } - - return recentSta; - } /** * 妫�娴嬫槸鍚︾┛姊溅鏄惁鏈夊厖鐢典换鍔� diff --git a/src/main/java/com/zy/core/enums/LiftCommandModeType.java b/src/main/java/com/zy/core/enums/LiftCommandModeType.java new file mode 100644 index 0000000..0fc389b --- /dev/null +++ b/src/main/java/com/zy/core/enums/LiftCommandModeType.java @@ -0,0 +1,48 @@ +package com.zy.core.enums; + +public enum LiftCommandModeType { + + NONE(-1, "鏈煡绫诲瀷"), + MOVE(1, "鎻愬崌鏈哄崌闄�"), +// PALLET_INOUT(2, "鎵樼洏鍑哄叆"), + LOCK(3, "閿佸畾鎻愬崌鏈�"), + UNLOCK(4, "瑙i攣鎻愬崌鏈�"), + RESET(5, "澶嶄綅"), + MOVE_CAR(6, "鎻愬崌鏈哄崌闄嶅皬杞�"), + PALLET_IN(7, "鎵樼洏鍏�"), + PALLET_OUT(8, "鎵樼洏鍑�"), + ; + + public Integer id; + public String desc; + + LiftCommandModeType(Integer id, String desc) { + this.id = id; + this.desc = desc; + } + + public static LiftCommandModeType get(Integer id) { + if (null == id) { + return null; + } + for (LiftCommandModeType type : LiftCommandModeType.values()) { + if (type.id.equals(id)) { + return type; + } + } + return null; + } + + public static LiftCommandModeType get(LiftCommandModeType type) { + if (null == type) { + return null; + } + for (LiftCommandModeType type1 : LiftCommandModeType.values()) { + if (type1 == type) { + return type1; + } + } + return null; + } + +} diff --git a/src/main/java/com/zy/core/enums/LiftProtocolStatusType.java b/src/main/java/com/zy/core/enums/LiftProtocolStatusType.java new file mode 100644 index 0000000..eed47bf --- /dev/null +++ b/src/main/java/com/zy/core/enums/LiftProtocolStatusType.java @@ -0,0 +1,43 @@ +package com.zy.core.enums; + +public enum LiftProtocolStatusType { + + NONE(-1, "鏈煡"), + IDLE(1, "绌洪棽"), + WORKING(2, "浣滀笟涓�"), + WAITING(3, "绛夊緟纭"), + OFFLINE(4, "绂荤嚎"), + ; + + public Integer id; + public String desc; + + LiftProtocolStatusType(Integer id, String desc) { + this.id = id; + this.desc = desc; + } + + public static LiftProtocolStatusType get(Integer id) { + if (null == id) { + return null; + } + for (LiftProtocolStatusType type : LiftProtocolStatusType.values()) { + if (type.id.equals(id.intValue())) { + return type; + } + } + return null; + } + + public static LiftProtocolStatusType get(LiftProtocolStatusType type) { + if (null == type) { + return null; + } + for (LiftProtocolStatusType type2 : LiftProtocolStatusType.values()) { + if (type2 == type) { + return type2; + } + } + return null; + } +} diff --git a/src/main/java/com/zy/core/enums/RedisKeyType.java b/src/main/java/com/zy/core/enums/RedisKeyType.java index 190f8d9..3800b70 100644 --- a/src/main/java/com/zy/core/enums/RedisKeyType.java +++ b/src/main/java/com/zy/core/enums/RedisKeyType.java @@ -6,6 +6,8 @@ SHUTTLE_FLAG("shuttle_"), FORK_LIFT_WORK_FLAG("fork_lift_wrk_no_"), FORK_LIFT_FLAG("fork_lift_"), + LIFT_WORK_FLAG("lift_wrk_no_"), + LIFT_FLAG("lift_"), MAP("realtimeBasMap_"), BASIC_MAP("basicMap_"), QUEUE_SHUTTLE("queue_shuttle_"), diff --git a/src/main/java/com/zy/core/enums/WrkStsType.java b/src/main/java/com/zy/core/enums/WrkStsType.java index 79b53ae..d371b2f 100644 --- a/src/main/java/com/zy/core/enums/WrkStsType.java +++ b/src/main/java/com/zy/core/enums/WrkStsType.java @@ -40,13 +40,33 @@ MOVE_SHUTTLE(310, "灏忚溅绉诲姩涓�"), COMPLETE_MOVE(311, "灏忚溅绉诲姩瀹屾垚"), - NEW_MANUAL(401, "鐢熸垚鎵嬪姩浠诲姟"), - ANALYZE_MANUAL(402, "鎵嬪姩浠诲姟瑙f瀽"), - EXECUTE_MANUAL(403, "鎵ц鎵嬪姩浠诲姟"), - COMPLETE_MANUAL(410, "鎵嬪姩浠诲姟瀹屾垚"), + MOVE_SITE_TRANSPORT_LIFT(322, "灏忚溅绉诲姩鑷崇珯鐐�"), + MOVE_SITE_COMPLETE_TRANSPORT_LIFT(333, "灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴�"), + MOVE_LIFT_TO_SHUTTLE_TRANSPORT_LIFT(334, "鎻愬崌鏈鸿嚦灏忚溅灞�"), + MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT(335, "鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴�"), + MOVE_IN_LIFT_TRANSPORT_LIFT(336, "灏忚溅杩佸叆鎻愬崌鏈轰腑"), + MOVE_IN_LIFT_COMPLETE_TRANSPORT_LIFT(337, "灏忚溅杩佸叆鎻愬崌鏈哄畬鎴�"), + MOVE_LIFT_TO_TARGET_TRANSPORT_LIFT(338, "鎻愬崌鏈鸿嚦鏀捐揣灞�"), + MOVE_LIFT_TO_TARGET_COMPLETE_TRANSPORT_LIFT(339, "鎻愬崌鏈鸿嚦鏀捐揣灞傚畬鎴�"), + MOVE_OUT_LIFT_TRANSPORT_LIFT(340, "灏忚溅杩佸嚭鎻愬崌鏈轰腑"), + MOVE_OUT_LIFT_COMPLETE_TRANSPORT_LIFT(341, "灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴�"), + MOVE_SHUTTLE_TRANSPORT_LIFT(342, "灏忚溅鏀捐揣涓�"), + COMPLETE_MOVE_TRANSPORT_LIFT(343, "灏忚溅鏀捐揣瀹屾垚"), + + CALL_SHUTTLE_TO_TAKE(351, "鍛煎彨灏忚溅鑷冲彇璐х偣"), + MOVE_SITE_TRANSPORT_LIFT_OUT(352, "灏忚溅绉诲姩鑷崇珯鐐�"), + MOVE_SITE_COMPLETE_TRANSPORT_LIFT_OUT(353, "灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴�"), + MOVE_LIFT_TO_SHUTTLE_TRANSPORT_LIFT_OUT(354, "鎻愬崌鏈鸿嚦灏忚溅灞�"), + MOVE_LIFT_TO_SHUTTLE_COMPLETE_TRANSPORT_LIFT_OUT(355, "鎻愬崌鏈鸿嚦灏忚溅灞傚畬鎴�"), + MOVE_IN_LIFT_TRANSPORT_LIFT_OUT(356, "灏忚溅杩佸叆鎻愬崌鏈轰腑"), + MOVE_IN_LIFT_COMPLETE_TRANSPORT_LIFT_OUT(357, "灏忚溅杩佸叆鎻愬崌鏈哄畬鎴�"), + MOVE_OUT_LIFT_TRANSPORT_LIFT_OUT(358, "灏忚溅杩佸嚭鎻愬崌鏈轰腑"), + MOVE_OUT_LIFT_COMPLETE_TRANSPORT_LIFT_OUT(359, "灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴�"), + COMPLETE_MOVE_TRANSPORT_LIFT_OUT(360, "灏忚溅鏀捐揣瀹屾垚"), NEW_LOC_MOVE(501, "鐢熸垚绉诲簱浠诲姟"), - LOC_MOVE_SHUTTLE_RUN(502, "灏忚溅鎼繍涓�"), + LOC_MOVE_SHUTTLE_TAKE(502, "灏忚溅鍙栬揣涓�"), + LOC_MOVE_SHUTTLE_PUT(503, "灏忚溅閫佽揣涓�"), COMPLETE_LOC_MOVE(509, "绉诲簱瀹屾垚"), ; diff --git a/src/main/java/com/zy/core/model/LiftSlave.java b/src/main/java/com/zy/core/model/LiftSlave.java index 6070ea0..16780c2 100644 --- a/src/main/java/com/zy/core/model/LiftSlave.java +++ b/src/main/java/com/zy/core/model/LiftSlave.java @@ -14,10 +14,22 @@ //鎻愬崌鏈虹珯鐐� private List<Sta> sta = new ArrayList<>(); - //杈撻�佺珯鐐规帓 + //鎺� + private Integer row; + + //鍒� + private Integer bay; + + //寰呮満浣嶆帓 + private Integer standByRow; + + //寰呮満浣嶅垪 + private Integer standByBay; + + //绔欑偣鎺� private Integer staRow; - //杈撻�佺珯鐐瑰垪 + //绔欑偣鍒� private Integer staBay; @Data diff --git a/src/main/java/com/zy/core/model/command/LiftAssignCommand.java b/src/main/java/com/zy/core/model/command/LiftAssignCommand.java index 145a836..7e60c6d 100644 --- a/src/main/java/com/zy/core/model/command/LiftAssignCommand.java +++ b/src/main/java/com/zy/core/model/command/LiftAssignCommand.java @@ -20,7 +20,7 @@ /** * 鍛戒护list */ - private List<ForkLiftCommand> commands; + private List<LiftCommand> commands; /** * 浣滀笟绫诲瀷 diff --git a/src/main/java/com/zy/core/model/command/LiftCommand.java b/src/main/java/com/zy/core/model/command/LiftCommand.java index 107441b..72aa3c4 100644 --- a/src/main/java/com/zy/core/model/command/LiftCommand.java +++ b/src/main/java/com/zy/core/model/command/LiftCommand.java @@ -1,5 +1,6 @@ package com.zy.core.model.command; +import com.zy.core.enums.LiftCommandModeType; import lombok.Data; @@ -10,85 +11,48 @@ public class LiftCommand { /** - * 鎻愬崌鏈哄彿 + * 鎻愬崌鏈虹紪鍙� */ - private Short liftNo = 0; + private Integer liftNo; /** - * 浠诲姟鍙� + * 浠诲姟鏍囪瘑鍙� */ - private Short taskNo = 0; + private Integer taskNo; /** - * 寮�濮嬭繍琛� + * 鍛戒护绫诲瀷 */ - private Short run; + private Integer mode = LiftCommandModeType.NONE.id; /** - * 鐩爣浣嶇疆 + * 婧愬眰 */ - private Short distPosition; + private Integer originLev; /** - * 杩愯閫熷害 + * 鐩爣灞� */ - private Short speed; + private Integer targetLev; /** - * 浜屽眰楂樺害璁惧畾(鎻愬崌鏈轰笌杈撻�佺嚎骞冲眰) + * 婧愮珯 */ - private Short height2; - - /** - * 涓夊眰楂樺害璁惧畾(瀹為檯鐨勪簩灞�) - */ - private Short height3; - - /** - * 鍥涘眰楂樺害璁惧畾(瀹為檯鐨勪笁灞�) - */ - private Short height4; - - /** - * 浜斿眰楂樺害璁惧畾(瀹為檯鐨勫洓灞�) - */ - private Short height5; - - /** - * 鎻愬崌鏈洪攣瀹� - */ - private Boolean liftLock; - - /** - * 鎿嶄綔杈撻�佺珯鐐瑰彿 - */ - private Short operaStaNo; - - /** - * 杈撻�佺嚎鑱斿姩杞姩鏂瑰悜锛�0锛氬仠姝㈣浆鍔紝1锛氭鍚戣浆鍔紝2锛氬弽鍚戣浆鍔� - */ - private Integer rotationDire; - - /** - * 杈撻�佺嚎ID - */ - private Integer devpId; + private Integer originSta; /** * 鐩爣绔� */ - private Short staNo; + private Integer targetSta; + + /** + * 鎶ユ枃鍐呭 + */ + private String body; /** * 鍛戒护鏄惁瀹屾垚,榛樿false鏈畬鎴� */ private Boolean complete = false; - - public Short getLiftLockShortValue() { - if (liftLock == null) { - return (short) 0; - } - return liftLock ? (short) 1 : (short) 0; - } } diff --git a/src/main/java/com/zy/core/model/protocol/LiftProtocol.java b/src/main/java/com/zy/core/model/protocol/LiftProtocol.java new file mode 100644 index 0000000..4451b72 --- /dev/null +++ b/src/main/java/com/zy/core/model/protocol/LiftProtocol.java @@ -0,0 +1,304 @@ +package com.zy.core.model.protocol; + +import com.core.common.Cools; +import com.core.common.SpringUtils; +import com.zy.asrs.entity.BasLiftErr; +import com.zy.asrs.service.BasLiftErrService; +import com.zy.common.utils.RedisUtil; +import com.zy.core.enums.LiftProtocolStatusType; +import com.zy.core.enums.RedisKeyType; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Data +public class LiftProtocol implements Cloneable { + + //**********************蹇呴』瀛樺湪灞炴��********************** + /** + * 鎻愬崌鏈哄彿 + */ + private Integer liftNo; + + /** + * 浠诲姟鍙� + */ + private Integer taskNo; + + /** + * 鍥涘悜绌挎杞﹀彿 + */ + private Integer shuttleNo = 0; + + /** + * 褰撳墠鎻愬崌鏈虹姸鎬侊紙鍐呴儴鑷垜缁存姢锛� + */ + private Integer protocolStatus = -1; + + /** + * 褰撳墠鎻愬崌鏈虹姸鎬佹灇涓� + */ + private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.NONE; + + /** + * 妯″紡 => 鑷姩/鎵嬪姩 + */ + private Boolean model; + + /** + * 杩愯鐘舵�� + */ + private Boolean run; + + /** + * 灏辩华鐘舵�� + */ + private Boolean ready; + + /** + * 鍓嶈秴闄� + */ + private Boolean frontOverrun; + + /** + * 鍚庤秴闄� + */ + private Boolean backOverrun; + + /** + * 宸﹁秴闄� + */ + private Boolean leftOverrun; + + /** + * 鍙宠秴闄� + */ + private Boolean rightOverrun; + + /** + * 瓒呴珮 + */ + private Boolean overHeight; + + /** + * 瓒呴噸 + */ + private Boolean overWeight; + + /** + * 鏈夋墭鐩� + */ + private Boolean hasTray; + + /** + * 鏈夊皬杞� + */ + private Boolean hasCar; + + /** + * 鏁呴殰 + */ + private Boolean error; + + /** + * 鏁呴殰鐮� + */ + private String errorCode; + + /** + * 浠诲姟鍦板潃 + */ + private Short taskAddress; + + /** + * 鐩殑鍦板潃 + */ + private Short distAddress; + + /** + * 宸插畬鎴愮殑浠诲姟鍙� + */ + private String completeTaskNo; + + /** + * 灞� + */ + private Integer lev; + + /** + * 浣滀笟鏍囪 + */ + private Boolean pakMk = true; + + /** + * 鎸囦护涓嬪彂鏃堕棿 + */ + private Long sendTime = 0L; + + /** + * 鏃ュ織閲囬泦鏃堕棿 + */ + private Long deviceDataLog = System.currentTimeMillis(); + + /** + * 鎵╁睍瀛楁 + */ + private Object extend; + + public String getRun$() { + if (this.run == null) { + return "鏈煡"; + } + + return this.run ? "杩愯涓�" : "绌洪棽"; + } + + public String getReady$() { + if (this.ready == null) { + return "鏈煡"; + } + + return this.ready ? "灏辩华" : "鏈氨缁�"; + } + + public String getModel$() { + if (this.model == null) { + return "鏈煡"; + } + + return this.model ? "鑷姩" : "鎵嬪姩"; + } + + public String getHasTray$() { + if (this.hasTray == null) { + return "鏈煡"; + } + + return this.hasTray ? "Y" : "N"; + } + + public String getHasCar$() { + if (this.hasCar == null) { + return "鏈煡"; + } + + return this.hasCar ? "Y" : "N"; + } + + public String getFrontOverrun$() { + if (this.frontOverrun == null) { + return "鏈煡"; + } + + return this.frontOverrun ? "Y" : "N"; + } + + public String getBackOverrun$() { + if (this.backOverrun == null) { + return "鏈煡"; + } + + return this.backOverrun ? "Y" : "N"; + } + + public String getLeftOverrun$() { + if (this.leftOverrun == null) { + return "鏈煡"; + } + + return this.leftOverrun ? "Y" : "N"; + } + + public String getRightOverrun$() { + if (this.rightOverrun == null) { + return "鏈煡"; + } + + return this.rightOverrun ? "Y" : "N"; + } + + public String getOverHeight$() { + if (this.overHeight == null) { + return "鏈煡"; + } + + return this.overHeight ? "Y" : "N"; + } + + public String getOverWeight$() { + if (this.overWeight == null) { + return "鏈煡"; + } + + return this.overWeight ? "Y" : "N"; + } + + public String getProtocolStatus$() { + if (this.protocolStatusType == null) { + return "鏈煡"; + } + + return this.protocolStatusType.desc; + } + + /** + * 璁剧疆鎻愬崌鏈虹姸鎬� + */ + public void setProtocolStatus(Integer status) { + this.protocolStatus = status; + this.protocolStatusType = LiftProtocolStatusType.get(status); + } + + /** + * 璁剧疆鎻愬崌鏈虹姸鎬� + */ + public void setProtocolStatus(LiftProtocolStatusType status) { + this.protocolStatus = status.id; + this.protocolStatusType = status; + } + + public synchronized void setTaskNo(Integer taskNo) { + RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); + if (null != redisUtil) { + redisUtil.set(RedisKeyType.LIFT_FLAG.key + this.liftNo, taskNo); + this.taskNo = taskNo; + } + } + + public Integer getTaskNo() { + RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); + if (null != redisUtil) { + Object o = redisUtil.get(RedisKeyType.LIFT_FLAG.key + this.liftNo); + if (!Cools.isEmpty(o)) { + this.taskNo = Integer.valueOf(String.valueOf(o)); + } + } + return this.taskNo == null ? 0 : this.taskNo; + } + + /** + * 閿欒鐮� + */ + public String getErrCode$() { + if (this.errorCode == null) { + return ""; + } + BasLiftErrService basLiftErrService = SpringUtils.getBean(BasLiftErrService.class); + BasLiftErr basLiftErr = basLiftErrService.selectById(this.errorCode); + if (basLiftErr == null) { + return String.valueOf(this.errorCode); + } + return basLiftErr.getErrName(); + } + + @Override + public LiftProtocol clone() { + try { + return (LiftProtocol) super.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java b/src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java index e52218b..1bb4b1a 100644 --- a/src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java +++ b/src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java @@ -26,6 +26,36 @@ private Boolean busy; /** + * 鍓嶈秴闄� + */ + private Boolean frontOverrun; + + /** + * 鍚庤秴闄� + */ + private Boolean backOverrun; + + /** + * 宸﹁秴闄� + */ + private Boolean leftOverrun; + + /** + * 鍙宠秴闄� + */ + private Boolean rightOverrun; + + /** + * 瓒呴珮 + */ + private Boolean overHeight; + + /** + * 瓒呴噸 + */ + private Boolean overWeight; + + /** * 鏈夋墭鐩� */ private Boolean hasTray; @@ -41,9 +71,13 @@ private Boolean deviceError; /** - * 浠诲姟鍙� + * 褰撳墠鎵ц浠诲姟鍙� */ private Short taskNo; + /** + * 宸插畬鎴愮殑浠诲姟鍙� + */ + private Short completeTaskNo; /** * 灞� diff --git a/src/main/java/com/zy/core/properties/SlaveProperties.java b/src/main/java/com/zy/core/properties/SlaveProperties.java index 74910e7..8e03698 100644 --- a/src/main/java/com/zy/core/properties/SlaveProperties.java +++ b/src/main/java/com/zy/core/properties/SlaveProperties.java @@ -25,6 +25,8 @@ private List<ShuttleSlave> shuttle = new ArrayList<>(); + private List<LiftSlave> lift = new ArrayList<>(); + private List<ForkLiftSlave> forkLift = new ArrayList<>(); private List<ForkLiftSlave> forkLiftMaster = new ArrayList<>(); diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java new file mode 100644 index 0000000..e8a7e30 --- /dev/null +++ b/src/main/java/com/zy/core/thread/LiftThread.java @@ -0,0 +1,67 @@ +package com.zy.core.thread; + +import com.zy.common.ExecuteSupport; +import com.zy.common.model.NavigateNode; +import com.zy.core.ThreadHandler; +import com.zy.core.enums.ForkLiftTaskModeType; +import com.zy.core.enums.LiftCommandModeType; +import com.zy.core.enums.LiftProtocolStatusType; +import com.zy.core.model.CommandResponse; +import com.zy.core.model.command.LiftCommand; +import com.zy.core.model.protocol.LiftProtocol; +import com.zy.core.model.protocol.LiftStaProtocol; + +import java.util.List; + +public interface LiftThread extends ThreadHandler { + + LiftProtocol getStatus();//鑾峰彇鎻愬崌鏈虹姸鎬� + + LiftProtocol getStatus(boolean clone);//鑾峰彇鎻愬崌鏈虹姸鎬� + + List<LiftStaProtocol> getLiftStaProtocols(); + + CommandResponse move(LiftCommand command);//鍗囬檷绉诲姩 + + CommandResponse palletInOut(LiftCommand command);//鎵樼洏鍑哄叆 + + CommandResponse lock(LiftCommand command);//閿佸畾鎻愬崌鏈� + + CommandResponse unlock(LiftCommand command);//瑙i攣鎻愬崌鏈� + + CommandResponse reset(LiftCommand command);//澶嶄綅 + + boolean isIdle();//鏄惁绌洪棽 + + boolean isDeviceIdle();//璁惧鏄惁绌洪棽 + + boolean isDeviceIdle(ExecuteSupport support);//璁惧鏄惁绌洪棽 + + boolean setProtocolStatus(LiftProtocolStatusType status);//璁剧疆宸ヤ綔鐘舵�� + + boolean setSyncTaskNo(Integer taskNo);//璁剧疆宸ヤ綔鍙� + + boolean isLock(ExecuteSupport support); + + int generateDeviceTaskNo(int taskNo, ForkLiftTaskModeType type);//鐢熸垚纭欢璁惧宸ヤ綔鍙� + + String getLiftLocNo(int lev);//鑾峰彇鎻愬崌鏈轰綅缃� + + String getLiftStandByLocNo(int lev);//鑾峰彇鎻愬崌鏈哄緟鏈轰綅 + + List<NavigateNode> getLiftStaNodes(int lev); + + //***************鑾峰彇鍛戒护***************** + List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode);//鎻愬崌鏈虹Щ鍔� + + List<LiftCommand> getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode);//杞借溅绉诲姩 + + List<LiftCommand> getPalletInCommand(Integer taskNo, Integer sourceLev, Integer targetLev);//鎵樼洏鍏� + + List<LiftCommand> getPalletOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev);//鎵樼洏鍑� + + List<LiftCommand> getLockCommand(Integer taskNo, Boolean lock);//閿佸畾/瑙i攣鎻愬崌鏈� + + List<LiftCommand> getShuttleSignalCommand(Integer taskNo, Boolean signal);//灏忚溅宸插埌浣�/宸查┒绂讳俊鍙� + +} diff --git a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java new file mode 100644 index 0000000..77a5e0d --- /dev/null +++ b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java @@ -0,0 +1,649 @@ +package com.zy.core.thread.impl; + +import HslCommunication.Core.Types.OperateResult; +import HslCommunication.Core.Types.OperateResultExOne; +import HslCommunication.Profinet.Siemens.SiemensPLCS; +import HslCommunication.Profinet.Siemens.SiemensS7Net; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.core.common.DateUtils; +import com.core.common.SpringUtils; +import com.core.exception.CoolException; +import com.zy.asrs.entity.BasLift; +import com.zy.asrs.entity.DeviceDataLog; +import com.zy.asrs.service.BasLiftService; +import com.zy.asrs.service.DeviceDataLogService; +import com.zy.asrs.utils.Utils; +import com.zy.common.ExecuteSupport; +import com.zy.common.model.NavigateNode; +import com.zy.common.service.CommonService; +import com.zy.common.utils.LiftUtils; +import com.zy.common.utils.NavigatePositionConvert; +import com.zy.common.utils.RedisUtil; +import com.zy.core.News; +import com.zy.core.action.ForkLiftAction; +import com.zy.core.action.LiftAction; +import com.zy.core.cache.OutputQueue; +import com.zy.core.enums.ForkLiftTaskModeType; +import com.zy.core.enums.LiftCommandModeType; +import com.zy.core.enums.LiftProtocolStatusType; +import com.zy.core.enums.RedisKeyType; +import com.zy.core.model.CommandResponse; +import com.zy.core.model.LiftSlave; +import com.zy.core.model.command.LiftCommand; +import com.zy.core.model.protocol.LiftProtocol; +import com.zy.core.model.protocol.LiftStaProtocol; +import com.zy.core.thread.LiftThread; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import java.text.MessageFormat; +import java.util.*; + +@Slf4j +@SuppressWarnings("all") +public class NyLiftThread implements LiftThread { + + private SiemensS7Net siemensS7Net; + private LiftSlave slave; + private LiftProtocol liftProtocol; + private RedisUtil redisUtil; + private List<LiftStaProtocol> liftStaProtocols = new ArrayList<>(); + + public static final HashMap<Integer, Integer> liftLevMap = new HashMap<Integer, Integer>() {{ + put(1, 101); + put(2, 102); + put(3, 103); + put(4, 104); + put(5, 105); + put(6, 106); + put(7, 107); + put(8, 108); + put(9, 109); + }}; + + public static final HashMap<Integer, List<String>> liftNodeMap = new HashMap<Integer, List<String>>() {{ + put(1, new ArrayList<String>(){{add("0200201");add("0200101");}}); + put(2, new ArrayList<String>(){{add("0200202");add("0200102");}}); + put(3, new ArrayList<String>(){{add("0200203");add("0200103");}}); + put(4, new ArrayList<String>(){{add("0200204");add("0200104");}}); + put(5, new ArrayList<String>(){{add("0200205");add("0200105");}}); + put(6, new ArrayList<String>(){{add("0200206");add("0200106");}}); + put(7, new ArrayList<String>(){{add("0200207");add("0200107");}}); + put(8, new ArrayList<String>(){{add("0200208");add("0200108");}}); + put(9, new ArrayList<String>(){{add("0200209");add("0200109");}}); + }}; + + public NyLiftThread(LiftSlave slave, RedisUtil redisUtil) { + this.slave = slave; + this.redisUtil = redisUtil; + //鍒濆鍖栫珯鐐� + for (LiftSlave.Sta sta : this.slave.getSta()) { + LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); + liftStaProtocol.setStaNo(sta.getStaNo());//绔欑偣鍙� + liftStaProtocol.setLev(sta.getLev());//绔欑偣妤煎眰 + String locNo = Utils.getLocNo(this.slave.getStaRow(), this.slave.getStaBay(), sta.getLev()); + liftStaProtocol.setLocNo(locNo);//绔欑偣搴撲綅鍙� + liftStaProtocol.setLiftNo(sta.getLiftNo());//鎻愬崌鏈哄彿 + liftStaProtocols.add(liftStaProtocol); + } + } + + @Override + public void run() { + News.info("{}鍙锋彁鍗囨満绾跨▼鍚姩", slave.getId()); + this.connect(); + while (true) { + try { + read(); + Thread.sleep(500); + execute(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private void execute() { + LiftAction liftAction = SpringUtils.getBean(LiftAction.class); + if (liftAction == null) { + return; + } + + Object object = redisUtil.get(RedisKeyType.LIFT_FLAG.key + slave.getId()); + if (object == null) { + return; + } + + Integer taskNo = Integer.valueOf(String.valueOf(object)); + if (taskNo != 0) { + //瀛樺湪浠诲姟闇�瑕佹墽琛� + boolean result = liftAction.executeWork(slave.getId(), taskNo); + } + } + + @Override + public List<LiftStaProtocol> getLiftStaProtocols() { + return this.liftStaProtocols; + } + + private void read() { + try { + readStatus(); + + //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓簍rue + if (liftProtocol.getRun()) { + liftProtocol.setPakMk(true); + } + } catch (Exception e) { + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); + } + } + + private void readStatus() { + try { + //鑾峰彇鎻愬崌鏈烘暟鎹� + OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB82.4.0", (short) 10); + if (result1.IsSuccess) { + if (null == liftProtocol) { + liftProtocol = new LiftProtocol(); + liftProtocol.setLiftNo(slave.getId()); + liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); + + InnerLiftExtend innerLiftExtend = new InnerLiftExtend(); + liftProtocol.setExtend(innerLiftExtend); + } + + //----------璇诲彇鎻愬崌鏈虹姸鎬�----------- + //璇诲彇4.0-4.7鏁版嵁 + boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result1.Content, 0, 1); + //璇诲彇5.0-5.7鏁版嵁 + boolean[] status2 = siemensS7Net.getByteTransform().TransBool(result1.Content, 1, 1); + //妯″紡 + liftProtocol.setModel(status1[0]); + //蹇欓棽 + liftProtocol.setRun(!status1[1]); + //鍓嶈秴闄� + liftProtocol.setFrontOverrun(status1[4]); + //鍚庤秴闄� + liftProtocol.setBackOverrun(status1[5]); + //宸﹁秴闄� + liftProtocol.setLeftOverrun(status1[6]); + //鍙宠秴闄� + liftProtocol.setRightOverrun(status1[7]); + //瓒呴珮 + liftProtocol.setOverHeight(status2[0]); + //瓒呴噸 + liftProtocol.setOverWeight(status2[1]); + //鏈夋墭鐩� + liftProtocol.setHasTray(status2[5]); + //鏈夊皬杞� + liftProtocol.setHasCar(status2[6]); + //璁惧鏁呴殰 + liftProtocol.setErrorCode(status2[7]?"1":"0"); + //鐩殑鍦板潃 + liftProtocol.setDistAddress(siemensS7Net.getByteTransform().TransInt16(result1.Content, 4)); + //宸插畬鎴愪换鍔″彿 + liftProtocol.setCompleteTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 6))); + //褰撳墠妤煎眰 + short lev = siemensS7Net.getByteTransform().TransInt16(result1.Content, 8); + liftProtocol.setLev((int) lev); + + //************琛ュ厖鎵╁睍瀛楁************* + InnerLiftExtend liftExtend = (InnerLiftExtend) liftProtocol.getExtend(); + //浠诲姟鍙� + liftExtend.setLiftTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 2))); + liftProtocol.setExtend(liftExtend); + + boolean ready = true; + if (!liftProtocol.getModel() || liftProtocol.getRun()) { + ready = false; + } + liftProtocol.setReady(ready);//灏辩华鐘舵�� + + + }else { + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆憑1}璇诲彇鎻愬崌鏈虹姸鎬佷俊鎭け璐�", DateUtils.convert(new Date()), slave.getId())); + throw new CoolException(MessageFormat.format( "璇诲彇鎻愬崌鏈虹姸鎬佷俊鎭け璐� ===>> [id:{0}] [ip:{1}] [port:{2}]", slave.getId(), slave.getIp(), slave.getPort())); + } + Thread.sleep(200); + + //鑾峰彇鎻愬崌鏈虹珯鐐规暟鎹� + OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB82.14.0", (short) (10 * liftStaProtocols.size())); + if (result1.IsSuccess) { + for (int i = 0; i < this.liftStaProtocols.size(); i++) { + LiftStaProtocol liftStaProtocol = liftStaProtocols.get(i); + int i1 = 0 + (i * 10); + int i2 = 1 + (i * 10); + //璇诲彇x4.0-x4.7鏁版嵁 + boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result2.Content, i1, 1); + //璇诲彇x5.0-x5.7鏁版嵁 + boolean[] status2 = siemensS7Net.getByteTransform().TransBool(result2.Content, i2, 1); + //妯″紡 + liftStaProtocol.setModel(status1[0]); + //蹇欓棽 + liftStaProtocol.setBusy(!status1[1]); + //鏈夋墭鐩� + liftStaProtocol.setHasTray(status1[2]); + //鍓嶈秴闄� + liftStaProtocol.setFrontOverrun(status1[4]); + //鍚庤秴闄� + liftStaProtocol.setBackOverrun(status1[5]); + //宸﹁秴闄� + liftStaProtocol.setLeftOverrun(status1[6]); + //鍙宠秴闄� + liftStaProtocol.setRightOverrun(status1[7]); + //瓒呴珮 + liftStaProtocol.setOverHeight(status2[0]); + //瓒呴噸 + liftStaProtocol.setOverWeight(status2[1]); + //鏈夊皬杞� + liftStaProtocol.setHasCar(status2[6]); + //璁惧鏁呴殰 + liftStaProtocol.setDeviceError(status2[7]); + //浠诲姟鍙� + liftStaProtocol.setTaskNo(siemensS7Net.getByteTransform().TransInt16(result2.Content, 2)); + //宸插畬鎴愪换鍔″彿 + liftStaProtocol.setCompleteTaskNo(siemensS7Net.getByteTransform().TransInt16(result2.Content, 6)); + } + } + + if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 5) { + //閲囬泦鏃堕棿瓒呰繃5s锛屼繚瀛樹竴娆℃暟鎹褰� + //淇濆瓨鏁版嵁璁板綍 + DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); + DeviceDataLog deviceDataLog = new DeviceDataLog(); + deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result1.Content)); + deviceDataLog.setWcsData(JSON.toJSONString(liftProtocol)); + deviceDataLog.setType("lift"); + deviceDataLog.setDeviceNo(slave.getId()); + deviceDataLog.setCreateTime(new Date()); + deviceDataLogService.insert(deviceDataLog); + + //鏇存柊閲囬泦鏃堕棿 + liftProtocol.setDeviceDataLog(System.currentTimeMillis()); + } + + //灏嗘彁鍗囨満鐘舵�佷繚瀛樿嚦鏁版嵁搴� + BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); + BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>() + .eq("lift_no", slave.getId())); + if (basLift == null) { + basLift = new BasLift(); + //鎻愬崌鏈哄彿 + basLift.setLiftNo(liftProtocol.getLiftNo()); + basLift.setStatus(1); + basLiftService.insert(basLift); + } + //浠诲姟鍙� + basLift.setWrkNo(liftProtocol.getTaskNo()); + //淇敼鏃堕棿 + basLift.setUpdateTime(new Date()); + //璁惧鐘舵�� + basLift.setDeviceStatus(JSON.toJSONString(liftProtocol)); + if (basLiftService.updateById(basLift)) { + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), liftProtocol.getLiftNo())); + } + + } catch (Exception e) { + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); + } + } + + @Override + public LiftProtocol getStatus() { + return getStatus(true); + } + + @Override + public LiftProtocol getStatus(boolean clone) { + if (this.liftProtocol == null) { + return null; + } + return clone ? this.liftProtocol.clone() : this.liftProtocol; + } + + @Override + public CommandResponse move(LiftCommand command) { + return write(command); + } + + @Override + public CommandResponse palletInOut(LiftCommand command) { + return write(command); + } + + private CommandResponse write(LiftCommand command) { + CommandResponse response = new CommandResponse(false); + if (null == command) { + News.error("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�"); + response.setMessage("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�"); + return response; + } + + List<Short> shorts = JSON.parseArray(command.getBody(), Short.class); + short[] array = new short[shorts.size()];//鑾峰彇鍛戒护鎶ユ枃 + for (int i = 0; i < shorts.size(); i++) { + array[i] = shorts.get(i); + } + + if (command.getTaskNo() != null) { + array[3] = command.getTaskNo().shortValue(); + } + + OperateResult result = siemensS7Net.Write("DB83.0", array); + if (result != null && result.IsSuccess) { + liftProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿 + News.info("鎻愬崌鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); + response.setMessage(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); + response.setResult(true); + return response; + } else { + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}],娆℃暟锛歿}", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); + News.error("鍐欏叆鎻愬崌鏈簆lc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + response.setMessage(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}],娆℃暟锛歿}", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); + return response; + } + } + + @Override + public CommandResponse lock(LiftCommand command) { + return new CommandResponse(true); + } + + @Override + public CommandResponse unlock(LiftCommand command) { + return new CommandResponse(true); + } + + @Override + public CommandResponse reset(LiftCommand command) { + return new CommandResponse(false); + } + + @Override + public boolean isIdle() { + // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂� + if (this.liftProtocol.getModel() + && this.liftProtocol.getTaskNo() == 0 + && !this.liftProtocol.getRun() + && this.liftProtocol.getReady() + && this.liftProtocol.getPakMk() + && this.liftProtocol.getErrorCode().equals("0") + && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE) + || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING)) + ) { + return true; + } + return false; + } + + @Override + public boolean isDeviceIdle() { + return isDeviceIdle(null); + } + + @Override + public boolean isDeviceIdle(ExecuteSupport support) { + if (null != support) { + Boolean judgement = support.judgement(); + if (judgement != null && !judgement) { + return true; + } + } + + // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂� + if (this.liftProtocol.getModel() + && !this.liftProtocol.getRun() + && this.liftProtocol.getReady() + && this.liftProtocol.getErrorCode().equals("0") + ) { + return true; + } + return false; + } + + @Override + public synchronized boolean setProtocolStatus(LiftProtocolStatusType status) { + this.liftProtocol.setProtocolStatus(status); + return true; + } + + @Override + public synchronized boolean setSyncTaskNo(Integer taskNo) { + this.liftProtocol.setTaskNo(taskNo); + return true; + } + + @Override + public boolean isLock(ExecuteSupport support) { + if (support != null) { + return support.judgement(); + } + return true; + } + + @Override + public int generateDeviceTaskNo(int taskNo, ForkLiftTaskModeType type) { + int deviceTaskNo = taskNo; + try { + CommonService commonService = SpringUtils.getBean(CommonService.class); + deviceTaskNo = commonService.getWorkNo(8); + } catch (Exception e) { + return taskNo; + } + return deviceTaskNo; + } + + @Override + public String getLiftLocNo(int lev) { + return Utils.getLocNo(slave.getRow(), slave.getBay(), lev); + } + + @Override + public String getLiftStandByLocNo(int lev) { + return Utils.getLocNo(slave.getStandByRow(), slave.getStandByBay(), lev); + } + + @Override + public List<NavigateNode> getLiftStaNodes(int lev) { + List<NavigateNode> targetNodes = new ArrayList<>(); + List<String> list = liftNodeMap.get(lev); + NavigateNode targetNode = NavigatePositionConvert.locNoToNode(list.get(0));//鐩爣鑺傜偣 + NavigateNode targetLastNode = NavigatePositionConvert.locNoToNode(list.get(1));//鐩爣鑺傜偣鍓嶄竴绔� + targetNodes.add(targetNode); + targetNodes.add(targetLastNode); + return targetNodes; + } + + @Override + public List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { + /** + * 浠诲姟绫诲瀷 + 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙� + 2=鎹㈠眰锛屽崌闄嶆満绉诲埌鐩爣灞傦紝绛夊緟 + 3=鍏ュ簱鎵樼洏,鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囧眰鏁帮紱 + 4=鍑哄簱鎵樼洏锛屽崌闄嶆満灏嗘簮绔欏彴鎵樼洏绉诲埌鐩爣绔欏彴 + */ + short taskMode = 2; + + Integer sourceData = liftLevMap.get(sourceLev); + Integer targetData = liftLevMap.get(targetLev); + + // 寮�濮嬩换鍔� + short[] array = new short[4]; + //浠诲姟绫诲瀷 + array[0] = taskMode; + //婧愮珯鍙扮紪鍙� + array[1] = sourceData.shortValue(); + //鐩爣绔欏彴缂栧彿 + array[2] = targetData.shortValue(); + //浠诲姟鍙� + array[3] = taskNo.shortValue(); + + LiftCommand command = new LiftCommand(); + command.setLiftNo(slave.getId()); + command.setBody(JSON.toJSONString(array)); + command.setMode(mode.id); + command.setOriginLev(sourceLev); + command.setTargetLev(targetLev); + + ArrayList<LiftCommand> list = new ArrayList<>(); + list.add(command); + return list; + } + + @Override + public List<LiftCommand> getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { + /** + * 浠诲姟绫诲瀷 + 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙� + 2=鎹㈠眰锛屽崌闄嶆満绉诲埌鐩爣灞傦紝绛夊緟 + 3=鍏ュ簱鎵樼洏,鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囧眰鏁帮紱 + 4=鍑哄簱鎵樼洏锛屽崌闄嶆満灏嗘簮绔欏彴鎵樼洏绉诲埌鐩爣绔欏彴 + 5=杞﹀拰鎵樼洏鍗囬檷 + */ + short taskMode = 5; + + Integer sourceData = liftLevMap.get(sourceLev); + Integer targetData = liftLevMap.get(targetLev); + + // 寮�濮嬩换鍔� + short[] array = new short[4]; + //浠诲姟绫诲瀷 + array[0] = taskMode; + //婧愮珯鍙扮紪鍙� + array[1] = sourceData.shortValue(); + //鐩爣绔欏彴缂栧彿 + array[2] = targetData.shortValue(); + //浠诲姟鍙� + array[3] = taskNo.shortValue(); + + LiftCommand command = new LiftCommand(); + command.setLiftNo(slave.getId()); + command.setBody(JSON.toJSONString(array)); + command.setMode(mode.id); + command.setOriginLev(sourceLev); + command.setTargetLev(targetLev); + + ArrayList<LiftCommand> list = new ArrayList<>(); + list.add(command); + return list; + } + + @Override + public List<LiftCommand> getPalletInCommand(Integer taskNo, Integer sourceLev, Integer targetLev) { + /** + * 浠诲姟绫诲瀷 + 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙� + 2=鎹㈠眰锛屽崌闄嶆満绉诲埌鐩爣灞傦紝绛夊緟 + 3=鍏ュ簱鎵樼洏,鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囧眰鏁帮紱 + 4=鍑哄簱鎵樼洏锛屽崌闄嶆満灏嗘簮绔欏彴鎵樼洏绉诲埌鐩爣绔欏彴 + */ + short taskMode = 3; + + // 寮�濮嬩换鍔� + short[] array = new short[4]; + //浠诲姟绫诲瀷 + array[0] = taskMode; + //婧愮珯鍙扮紪鍙� + array[1] = sourceLev.shortValue(); + //鐩爣绔欏彴缂栧彿 + array[2] = targetLev.shortValue(); + //浠诲姟鍙� + array[3] = taskNo.shortValue(); + + LiftCommand command = new LiftCommand(); + command.setLiftNo(slave.getId()); + command.setBody(JSON.toJSONString(array)); + command.setMode(LiftCommandModeType.PALLET_IN.id); + command.setOriginLev(sourceLev); + command.setTargetLev(targetLev); + + ArrayList<LiftCommand> list = new ArrayList<>(); + list.add(command); + return list; + } + + @Override + public List<LiftCommand> getPalletOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev) { + /** + * 浠诲姟绫诲瀷 + 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙� + 2=鎹㈠眰锛屽崌闄嶆満绉诲埌鐩爣灞傦紝绛夊緟 + 3=鍏ュ簱鎵樼洏,鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囧眰鏁帮紱 + 4=鍑哄簱鎵樼洏锛屽崌闄嶆満灏嗘簮绔欏彴鎵樼洏绉诲埌鐩爣绔欏彴 + */ + short taskMode = 4; + + // 寮�濮嬩换鍔� + short[] array = new short[4]; + //浠诲姟绫诲瀷 + array[0] = taskMode; + //婧愮珯鍙扮紪鍙� + array[1] = sourceLev.shortValue(); + //鐩爣绔欏彴缂栧彿 + array[2] = targetLev.shortValue(); + //浠诲姟鍙� + array[3] = taskNo.shortValue(); + + LiftCommand command = new LiftCommand(); + command.setLiftNo(slave.getId()); + command.setBody(JSON.toJSONString(array)); + command.setMode(LiftCommandModeType.PALLET_OUT.id); + command.setOriginLev(sourceLev); + command.setTargetLev(targetLev); + + ArrayList<LiftCommand> list = new ArrayList<>(); + list.add(command); + return list; + } + + @Override + public List<LiftCommand> getLockCommand(Integer taskNo, Boolean lock) { + return null; + } + + @Override + public List<LiftCommand> getShuttleSignalCommand(Integer taskNo, Boolean signal) { + return null; + } + + @Override + public boolean connect() { + boolean result = false; + //-------------------------鎻愬崌鏈鸿繛鎺ユ柟娉�------------------------// + siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp()); + OperateResult connect = siemensS7Net.ConnectServer(); + if(connect.IsSuccess){ + result = true; + OutputQueue.LIFT.offer(MessageFormat.format( "銆恵0}銆戞彁鍗囨満plc杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); + log.info("鎻愬崌鏈簆lc杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); + } else { + OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戞彁鍗囨満plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); + log.error("鎻愬崌鏈簆lc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); + } + siemensS7Net.ConnectClose(); + //-------------------------鎻愬崌鏈鸿繛鎺ユ柟娉�------------------------// + return result; + } + + @Override + public void close() { + siemensS7Net.ConnectClose(); + } + + /** + * 鎵╁睍瀛楁 + */ + @Data + private class InnerLiftExtend { + + /** + * 鎻愬崌鏈哄唴閮ㄥ伐浣滃彿 + */ + private String liftTaskNo; + + } + +} diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java index 20882be..3ec0f5a 100644 --- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java @@ -914,8 +914,8 @@ data.put("xp", xp); data.put("yp", yp); data.put("z", z); - data.put("x", mapNode.getXBase()); - data.put("y", mapNode.getYBase()); + data.put("x", mapNode.getYBase()); + data.put("y", mapNode.getXBase()); path.add(data); } @@ -1031,8 +1031,8 @@ location.put("xp", row); location.put("yp", bay); location.put("z", lev); - location.put("x", mapNode.getXBase()); - location.put("y", mapNode.getYBase()); + location.put("x", mapNode.getYBase()); + location.put("y", mapNode.getXBase()); HashMap<String, Object> body = new HashMap<>(); body.put("responseType", "init");//澶嶄綅 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4a6afa3..bf4da6a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,7 +11,7 @@ validation-timeout: 3000 connection-test-query: select 1 driver-class-name: com.mysql.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/shuttle_rcs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai + url: jdbc:mysql://127.0.0.1:3306/fyxc_shuttle?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: root mvc: @@ -44,54 +44,31 @@ # 涓嬩綅鏈洪厤缃� wcs-slave: - # 鍥涘悜绌挎杞�1 - shuttle[0]: - id: 1 - ip: 10.10.20.11 - port: 8888 - rack: 0 - slot: 0 - threadImpl: NyShuttleThread +# # 鍥涘悜绌挎杞�1 +# shuttle[0]: +# id: 1 +# ip: 192.168.10.81 +# port: 8888 +# rack: 0 +# slot: 0 +# threadImpl: NyShuttleThread # 鍥涘悜绌挎杞�2 - shuttle[1]: + shuttle[0]: id: 2 - ip: 10.10.20.12 + ip: 192.168.10.83 port: 8888 rack: 0 slot: 0 threadImpl: NyShuttleThread - # 璐у弶鎻愬崌鏈轰富绾跨▼ - forkLiftMaster[0]: - id: 99 - ip: 10.10.20.20 - port: 102 - rack: 0 - slot: 0 - threadImpl: LfdZyForkLiftMasterThread - # 璐у弶鎻愬崌鏈�1 - forkLift[0]: + # 鎻愬崌鏈�1 + lift[0]: id: 1 - ip: 10.10.20.20 + ip: 192.168.10.51 port: 102 - rack: 0 - slot: 0 - threadImpl: LfdZyForkLiftSlaveThread - masterId: 99 - staRow: 9 - staBay: 6 - sta[0]: - staNo: 1001 - lev: 1 - liftNo: ${wcs-slave.forkLift[0].id} - sta[1]: - staNo: 1002 - lev: 2 - liftNo: ${wcs-slave.forkLift[0].id} - sta[2]: - staNo: 1003 - lev: 3 - liftNo: ${wcs-slave.forkLift[0].id} - sta[3]: - staNo: 1004 - lev: 4 - liftNo: ${wcs-slave.forkLift[0].id} \ No newline at end of file + threadImpl: NyLiftThread + row: 2 + bay: 3 + standByRow: 2 + standByBay: 1 + staRow: 2 + staBay: 1 diff --git a/src/main/resources/mapper/WrkMastMapper.xml b/src/main/resources/mapper/WrkMastMapper.xml index 60065a7..4025668 100644 --- a/src/main/resources/mapper/WrkMastMapper.xml +++ b/src/main/resources/mapper/WrkMastMapper.xml @@ -130,7 +130,7 @@ <select id="selectShuttleMoveWrk" resultMap="BaseResultMap"> select * from asr_wrk_mast where 1=1 - and wrk_sts in (301,302,303,304,305,306,307,308,309,310,311) +-- and wrk_sts in (301,302,303,304,305,306,307,308,309,310,311) and io_type = 200 order by io_pri desc,io_time,wrk_no asc </select> diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html index 4d9e1c8..67de5a0 100644 --- a/src/main/webapp/views/index.html +++ b/src/main/webapp/views/index.html @@ -19,7 +19,7 @@ <div class="nav"> <ul class="cl-effect-4"> <li><a id="console" onclick="nav(this.id)" class="nav-select" href="#">涓绘帶鍥�</a></li> - <li><a id="forklift" onclick="nav(this.id)" class="nav-unselect" href="#">鎻愬崌鏈�</a></li> + <li><a id="lift" onclick="nav(this.id)" class="nav-unselect" href="#">鎻愬崌鏈�</a></li> <li><a id="shuttle" onclick="nav(this.id)" class="nav-unselect" href="#">鍥涘悜绌挎杞�</a></li> <li><a id="admin" onclick="nav(this.id)" class="nav-unselect" href="#">绠$悊鍚庡彴</a></li> </ul> diff --git a/src/main/webapp/views/lift.html b/src/main/webapp/views/lift.html index f8db854..1fdcf83 100644 --- a/src/main/webapp/views/lift.html +++ b/src/main/webapp/views/lift.html @@ -55,13 +55,10 @@ <tr> <th>鎻愬崌鏈�</th> <th>宸ヤ綔鍙�</th> - <th>浠诲姟鍦板潃</th> - <th>鐩殑鍦板潃</th> <th>宸插畬鎴愮殑浠诲姟鍙�</th> <th>灞�</th> <th>浣滀笟鏍囪</th> <th>绌挎杞﹀彿</th> - <th>浠ょ墝</th> </tr> </thead> <tbody> @@ -102,7 +99,6 @@ <option value="7">7F</option> <option value="8">8F</option> <option value="9">9F</option> - <option value="10">10F</option> </select> <button class="item" onclick="liftOperator(1)">绉诲姩鎻愬崌鏈�</button> @@ -114,8 +110,12 @@ <span>鐩爣绔�</span> <label><input id="staNo" type="text" name="staNo" /></label> </div> - <button class="item" onclick="liftOperator(2)">绉诲姩鎵樼洏</button> + <button class="item" onclick="liftOperator(5)">鎵樼洏鍏�</button> + <button class="item" onclick="liftOperator(6)">鎵樼洏鍑�</button> + <button class="item" onclick="liftOperator(7)">绉诲姩</button> + <button class="item" onclick="liftOperator(8)">杞﹁揣绉诲姩</button> <button class="item" onclick="liftOperator(0)">澶嶄綅</button> + <button class="item" onclick="liftOperator(3)">绛夊緟纭</button> </div> </fieldset> </div> @@ -144,12 +144,6 @@ <label class="form-label">浣滀笟鏍囪:</label> <div class="form-input"> <input id="pakMk" name="pakMk" type="text" class="layui-input" autocomplete="off"> - </div> - </div> - <div class="form-item"> - <label class="form-label">浠ょ墝:</label> - <div class="form-input"> - <input id="token" name="token" type="text" class="layui-input" autocomplete="off"> </div> </div> <div class="form-item form-button-container"> @@ -216,7 +210,6 @@ liftNo: $('#liftNo').val(), workNo: $('#workNo').val(), pakMk: $('#pakMk').val(), - token: $('#token').val(), }, function (res) { layer.msg("淇敼鎴愬姛", {icon: 1,}); layer.close(layerDetl); @@ -277,10 +270,10 @@ setVal(tr.children("td").eq(1), table[i-1].taskNo); setVal(tr.children("td").eq(2), table[i-1].protocolStatus$); setVal(tr.children("td").eq(3), table[i-1].model$); - setVal(tr.children("td").eq(4), table[i-1].busy$); + setVal(tr.children("td").eq(4), table[i-1].run$); setVal(tr.children("td").eq(5), table[i-1].hasTray$); setVal(tr.children("td").eq(6), table[i-1].hasCar$); - setVal(tr.children("td").eq(7), table[i-1].deviceError$); + setVal(tr.children("td").eq(7), table[i-1].errCode$); setVal(tr.children("td").eq(8), table[i-1].frontOverrun$); setVal(tr.children("td").eq(9), table[i-1].backOverrun$); setVal(tr.children("td").eq(10), table[i-1].leftOverrun$); @@ -316,13 +309,10 @@ var tr = tableEl.find("tr").eq(i); setVal(tr.children("td").eq(0), table[i-1].liftNo); setVal(tr.children("td").eq(1), table[i-1].workNo); - setVal(tr.children("td").eq(2), table[i-1].taskAddress); - setVal(tr.children("td").eq(3), table[i-1].distAddress); - setVal(tr.children("td").eq(4), table[i-1].completeTaskNo); - setVal(tr.children("td").eq(5), table[i-1].lev); - setVal(tr.children("td").eq(6), table[i-1].pakMk); - setVal(tr.children("td").eq(7), table[i-1].shuttleNo); - setVal(tr.children("td").eq(8), table[i-1].token); + setVal(tr.children("td").eq(2), table[i-1].completeTaskNo); + setVal(tr.children("td").eq(3), table[i-1].lev); + setVal(tr.children("td").eq(4), table[i-1].pakMk); + setVal(tr.children("td").eq(5), table[i-1].shuttleNo); } } else if (res.code === 403){ window.location.href = baseUrl+"/login"; -- Gitblit v1.9.1