| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.MapExcelNodeType; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.core.enums.MapNodeType; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Component |
| | | public class MapExcelUtils { |
| | |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | MapNode node = new MapNode(); |
| | | node.setId(row + "-" + bay); |
| | | node.setRow(row); |
| | | node.setBay(bay); |
| | | |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | String nodeType = nodeData.get("bgColor").toString(); |
| | |
| | | mapList.add(rows); |
| | | } |
| | | |
| | | MapNode baseMapNode = null; |
| | | //生成小车地图坐标间距数据 |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | |
| | | Integer left = bayData.getInteger("left"); |
| | | Integer right = bayData.getInteger("right"); |
| | | |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | String nodeValue = nodeData.get("value").toString(); |
| | | if (Utils.isJSON(nodeValue)) { |
| | | JSONObject jsonData = JSON.parseObject(nodeValue); |
| | | if (jsonData.containsKey("top")) { |
| | | top = jsonData.getInteger("top"); |
| | | } |
| | | if (jsonData.containsKey("bottom")) { |
| | | bottom = jsonData.getInteger("bottom"); |
| | | } |
| | | if (jsonData.containsKey("left")) { |
| | | left = jsonData.getInteger("left"); |
| | | } |
| | | if (jsonData.containsKey("right")) { |
| | | right = jsonData.getInteger("right"); |
| | | } |
| | | |
| | | if (jsonData.containsKey("xBase")) { |
| | | //基点 |
| | | baseMapNode = mapNode; |
| | | } |
| | | } |
| | | |
| | | mapNode.setTop(top); |
| | | mapNode.setBottom(bottom); |
| | | mapNode.setLeft(left); |
| | |
| | | } |
| | | } |
| | | |
| | | //生成牛眼Y坐标基准数据 |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | int yBase = 10000; |
| | | if (baseMapNode == null) { |
| | | throw new CoolException("未设置基准点"); |
| | | } |
| | | |
| | | List<Integer> rowList = new ArrayList<>(); |
| | | List<Integer> bayList = new ArrayList<>(); |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | rowList.add(row); |
| | | } |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | bayList.add(bay); |
| | | } |
| | | |
| | | if (baseMapNode.getRow() != 1) { |
| | | Collections.reverse(rowList); |
| | | } |
| | | |
| | | if (baseMapNode.getBay() != 1) { |
| | | Collections.reverse(bayList); |
| | | } |
| | | |
| | | //生成牛眼Y坐标基准数据 |
| | | for (int i = 0; i < bayList.size(); i++) { |
| | | Integer bay = bayList.get(i); |
| | | int yBase = 10000; |
| | | for (int j = 0; j < rowList.size(); j++) { |
| | | Integer row = rowList.get(j); |
| | | MapNode mapNode = mapList.get(row - 1).get(bay - 1); |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | |
| | | JSONObject rowData = rowMap.get(row); |
| | | Integer bottom = rowData.getInteger("bottom"); |
| | | String nodeValue = nodeData.get("value").toString(); |
| | | if (Utils.isJSON(nodeValue)) { |
| | | JSONObject jsonData = JSON.parseObject(nodeValue); |
| | | if (jsonData.containsKey("bottom")) { |
| | | bottom = jsonData.getInteger("bottom"); |
| | | } |
| | | } |
| | | |
| | | if (row != 1) { |
| | | yBase += bottom; |
| | | } |
| | | mapNode.setYBase(yBase); |
| | | |
| | | if (baseMapNode.getRow() == 1) { |
| | | yBase += mapNode.getBottom(); |
| | | }else { |
| | | yBase += mapNode.getTop(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //生成牛眼X坐标基准数据 |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | for (int i = 0; i < rowList.size(); i++) { |
| | | Integer row = rowList.get(i); |
| | | int xBase = 10000; |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | for (int j = 0; j < bayList.size(); j++) { |
| | | Integer bay = bayList.get(j); |
| | | MapNode mapNode = mapList.get(row - 1).get(bay - 1); |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | |
| | | JSONObject bayData = bayMap.get(bay); |
| | | Integer right = bayData.getInteger("right"); |
| | | String nodeValue = nodeData.get("value").toString(); |
| | | if (Utils.isJSON(nodeValue)) { |
| | | JSONObject jsonData = JSON.parseObject(nodeValue); |
| | | if (jsonData.containsKey("right")) { |
| | | right = jsonData.getInteger("right"); |
| | | } |
| | | } |
| | | |
| | | if (bay != 1) { |
| | | xBase += right; |
| | | } |
| | | mapNode.setXBase(xBase); |
| | | |
| | | if (baseMapNode.getBay() == 1) { |
| | | xBase += mapNode.getRight(); |
| | | }else { |
| | | xBase += mapNode.getLeft(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | |
| | | //小车(x,y)命令运行方向颠倒 |
| | | boolean shuttleDirectionReverse = false; |
| | | if (systemConfigMapObj != null) { |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj; |
| | | if (systemConfigMap.get("shuttleDirectionReverse").equals("Y")) { |
| | | shuttleDirectionReverse = true; |
| | | } |
| | | } |
| | | |
| | | long calcStartTime = System.currentTimeMillis(); |
| | | List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites); |
| | | if (nodeList == null) { |
| | |
| | | |
| | | long startGetMoveCommandTime = System.currentTimeMillis(); |
| | | //获取移动命令 |
| | | ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes); |
| | | ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, shuttleDirectionReverse); |
| | | News.info("[RCS Debug] getMoveCommand idx:{} time:{}", i, (System.currentTimeMillis() - startGetMoveCommandTime)); |
| | | |
| | | if (i + 1 == data.size()) { |
| | | long startGetInOutLiftTime = System.currentTimeMillis(); |
| | | if (moveType.equals("inLift")) { |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true); |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true, shuttleDirectionReverse); |
| | | }else if (moveType.equals("outLift")) { |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false); |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false, shuttleDirectionReverse); |
| | | } |
| | | News.info("[RCS Debug] getInOutLiftTime idx:{} time:{}", i, (System.currentTimeMillis() - startGetInOutLiftTime)); |
| | | } |
| | |
| | | |
| | | //小车移动连续下发指令 |
| | | boolean shuttleMoveCommandsContinuously = false; |
| | | Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (object != null) { |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) object; |
| | | if (systemConfigMapObj != null) { |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj; |
| | | String shuttleMoveCommandsContinuouslyConfig = systemConfigMap.get("shuttleMoveCommandsContinuously"); |
| | | if (shuttleMoveCommandsContinuouslyConfig != null && shuttleMoveCommandsContinuouslyConfig.equals("Y")) { |
| | | shuttleMoveCommandsContinuously = true; |
| | |
| | | |
| | | //***************获取命令***************** |
| | | |
| | | ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes);//获取移动命令 |
| | | ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean shuttleDirectionReverse);//获取移动命令 |
| | | |
| | | ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn);//获取移动命令 |
| | | ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn, Boolean shuttleDirectionReverse);//获取移动命令 |
| | | |
| | | ShuttleCommand getLiftCommand(Integer taskNo, Boolean lift);//顶升命令 true=>顶升 false=>下降 |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) { |
| | | public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean shuttleDirectionReverse) { |
| | | NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); |
| | | NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); |
| | | NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); |
| | |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); |
| | | Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum)); |
| | | int xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | |
| | | int xp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | if (shuttleDirectionReverse) { |
| | | xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | } |
| | | |
| | | int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); |
| | | |
| | | List<MapNode> mapNodes = mapData.get(node.getX()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn) { |
| | | public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn, Boolean shuttleDirectionReverse) { |
| | | NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); |
| | | NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); |
| | | NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); |
| | |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); |
| | | Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum)); |
| | | int xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | |
| | | int xp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | if (shuttleDirectionReverse) { |
| | | xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | } |
| | | |
| | | int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); |
| | | |
| | | List<MapNode> mapNodes = mapData.get(node.getX()); |
| | |
| | | |
| | | //WCS系统坐标转牛眼坐标 |
| | | private static int[] WCSXyzToNyXyz(int x, int y, int z) { |
| | | // //WCS系统Y轴 => 牛眼X轴转换公式 |
| | | // int x1 = Math.abs(y - 61) + 11; |
| | | // //WCS系统X轴 => 牛眼Y轴转换公式 |
| | | // int y1 = x + 10; |
| | | |
| | | // int x1 = x + 10; |
| | | // int y1 = y + 10; |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("row1", x) |
| | |
| | | |
| | | String qrCodeValue = locMast.getQrCodeValue(); |
| | | JSONObject data = JSON.parseObject(qrCodeValue); |
| | | return new int[]{data.getInteger("y"), data.getInteger("x"), z}; |
| | | return new int[]{data.getInteger("x"), data.getInteger("y"), z}; |
| | | } |
| | | |
| | | @Override |
| | |
| | | </div> |
| | | |
| | | <div class="show-box"> |
| | | <div>小车(x,y)命令运行方向颠倒</div> |
| | | <el-radio border v-model="codeMap.shuttleDirectionReverse" label="Y">开</el-radio> |
| | | <el-radio border v-model="codeMap.shuttleDirectionReverse" label="N">关</el-radio> |
| | | </div> |
| | | |
| | | <div class="show-box"> |
| | | <div>小车出提升机近点距离</div> |
| | | <el-input v-model="codeMap.shuttleOutLiftLocationDistance" style="width: 60%;"></el-input> |
| | | </div> |
| | |
| | | data.push('avoidInnerCircle'); |
| | | data.push('avoidOuterCircle'); |
| | | data.push('direction_map'); |
| | | data.push('shuttleDirectionReverse'); |
| | | data.push('shuttleOutLiftLocationDistance'); |
| | | data.push('shuttleMoveCommandsContinuously'); |
| | | data.push('trafficControlRestartCalcPath'); |