src/main/java/com/zy/asrs/entity/WrkMast.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/model/NavigateNode.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/utils/NavigateUtils.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/utils/RedisUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/enums/ShuttleRunDirection.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/asrs/entity/WrkMast.java
@@ -322,6 +322,13 @@ @TableField("full_plt") private String fullPlt; /** * 四向穿梭车号 */ @ApiModelProperty(value= "四向穿梭车号") @TableField("shuttle_no") private Integer shuttleNo; public String getWrkSts$(){ BasWrkStatusMapper mapper = SpringUtils.getBean(BasWrkStatusMapper.class); BasWrkStatus entity = mapper.selectById(this.wrkSts); src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -10,15 +10,11 @@ import com.zy.asrs.mapper.*; import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; import com.zy.common.model.LocTypeDto; import com.zy.common.model.MatDto; import com.zy.common.model.SearchLocParam; import com.zy.common.model.StartupDto; import com.zy.common.model.*; import com.zy.common.model.enums.WrkChargeType; import com.zy.common.service.CommonService; import com.zy.common.service.erp.ErpService; import com.zy.common.utils.CollectionUtils; import com.zy.common.utils.HttpHandler; import com.zy.common.utils.*; import com.zy.core.CrnThread; import com.zy.core.DevpThread; import com.zy.core.News; @@ -28,6 +24,7 @@ import com.zy.core.model.*; import com.zy.core.model.command.CrnCommand; import com.zy.core.model.command.LedCommand; import com.zy.core.model.command.ShuttleCommand; import com.zy.core.model.command.SteCommand; import com.zy.core.model.protocol.CrnProtocol; import com.zy.core.model.protocol.ShuttleProtocol; @@ -94,6 +91,8 @@ private OrderMapper orderMapper; @Autowired private OrderDetlMapper orderDetlMapper; @Autowired private RedisUtil redisUtil; /** * 组托 @@ -624,7 +623,93 @@ // 只有当四向穿梭车空闲 并且无任务时才继续执行 if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE && shuttleProtocol.getTaskNo() == 0) { //入出库逻辑 //..... for (WrkMast wrkSts : wrkMastMapper.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 2))) { //分配任务号 shuttleProtocol.setTaskNo(wrkSts.getWrkNo().shortValue()); //分配源库位 shuttleProtocol.setSourceLocNo(wrkSts.getSourceLocNo()); //分配目标库位 shuttleProtocol.setLocNo(wrkSts.getLocNo()); //计算路径 List<NavigateNode> calc = NavigateUtils.calc(wrkSts.getSourceLocNo(), wrkSts.getLocNo(), "in"); //获取分段路径 ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(calc); //将此map存入redis中 HashMap<String, Object> map = new HashMap<>(); //执行步序 map.put("step", 0); //路径数据 map.put("path", data); //工作号 map.put("wrk_no", wrkSts.getWrkNo()); //任务数据保存到redis redisUtil.set("wrk_no_" + wrkSts.getWrkNo().shortValue(), JSON.toJSONString(map)); } } else if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE && shuttleProtocol.getTaskNo() != 0) { //四向穿梭车空闲 并且有任务 Object o = redisUtil.get("wrk_no_" + shuttleProtocol.getTaskNo()); HashMap map = JSON.parseObject(o.toString(), HashMap.class); //当前步序 int step = Integer.parseInt(map.get("step").toString()); //当前路径数据 Object data = map.get("path"); ArrayList pathList = JSON.parseObject(data.toString(), ArrayList.class); //取第一条路径 Object o1 = pathList.get(step); ArrayList path = JSON.parseObject(o1.toString(), ArrayList.class); int size = path.size(); //开始路径 JSONObject startPath = JSON.parseObject(path.get(0).toString()); System.out.println(startPath); //目标路径 JSONObject endPath = JSON.parseObject(path.get(size - 1).toString()); System.out.println(endPath); //下发命令 ShuttleCommand command = new ShuttleCommand(); command.setCommandWord((short) 1); command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getIntValue("x"), startPath.getIntValue("y"))); command.setMiddleCodeNum((short) 0); command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getIntValue("x"), endPath.getIntValue("y"))); command.setStartToDistDistance(1000); command.setMiddleToDistDistance(1000); command.setRunDirection(ShuttleRunDirection.get(startPath.get("direction").toString()).id); command.setPalletLift((short) 1); command.setForceMoveDistance(1000); command.setChargeSwitch((short) 2); command.setIOControl((short) 0); command.setRunSpeed((short) 1000); command.setRadarTmp((short) 0); command.setCommandEnd((short) 1); if (!MessageQueue.offer(SlaveType.Shuttle, shuttleProtocol.getShuttleNo().intValue(), new Task(2, command))) { News.error("四向穿梭车命令下发失败,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); } else { News.info("四向穿梭车命令下发成功,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); //判断数据是否执行完成 if (step < size) { //更新redis数据 //步序增加 step++; map.put("step", step); //任务数据保存到redis redisUtil.set("wrk_no_" + map.get("wrk_no").toString(), JSON.toJSONString(map)); }else { //已执行完成 //保存数据到数据库做流水 //删除redis redisUtil.del("wrk_no_" + map.get("wrk_no").toString()); //。。。 //1、命令下方需要判断小车空闲状态 //2、 } } } } src/main/java/com/zy/common/model/NavigateNode.java
@@ -15,7 +15,7 @@ private int H;//将要花费的步数 private NavigateNode Father;//父节点 private Boolean isInflectionPoint;//是否为拐点 private String direction;//拐点方向 private String direction;//行走方向 public NavigateNode(int x, int y) { this.x = x; src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -126,6 +126,7 @@ public static ArrayList<ArrayList<NavigateNode>> getSectionPath(List<NavigateNode> mapList) { ArrayList<ArrayList<NavigateNode>> list = new ArrayList<>(); ArrayList<NavigateNode> data = new ArrayList<>(); String direction = mapList.get(0).getDirection();//行走方向 for (NavigateNode mapNode : mapList) { boolean isInflectionPoint = mapNode.getIsInflectionPoint(); data.add(mapNode); @@ -133,7 +134,11 @@ //拐点 //分割数据 list.add(data);//添加某一段数据 direction = mapNode.getDirection();//更新行走方向 data = new ArrayList<>(); }else { //直行线路 mapNode.setDirection(direction);//设置行走方向 } } src/main/java/com/zy/common/utils/RedisUtil.java
@@ -2,6 +2,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.List; @@ -13,13 +15,16 @@ * redisTemplate封装 * */ //@Component @Component public class RedisUtil { @Autowired private RedisTemplate<String, Object> redisTemplate; // @Autowired // private RedisTemplate<String, Object> redisTemplate; public RedisUtil(RedisTemplate<String, Object> redisTemplate) { @Autowired private RedisTemplate redisTemplate; public RedisUtil(RedisTemplate redisTemplate) { this.redisTemplate = redisTemplate; } src/main/java/com/zy/core/enums/ShuttleRunDirection.java
New file @@ -0,0 +1,63 @@ package com.zy.core.enums; /** * 四向穿梭车运行方向 */ public enum ShuttleRunDirection { TOP((short)1, "货物方向+"), BOTTOM((short)2, "货物方向-"), LEFT((short)3, "过道方向+"), RIGHT((short)4, "过道方向-"), ; public Short id; public String desc; ShuttleRunDirection(Short id,String desc) { this.id = id; this.desc = desc; } public static ShuttleRunDirection get(String direction) { if (null == direction) { return null; } if (direction.equals("top")) { return TOP; } else if (direction.equals("bottom")) { return BOTTOM; } else if (direction.equals("left")) { return LEFT; } else if (direction.equals("right")) { return RIGHT; }else { return null; } } public static ShuttleRunDirection get(Short id) { if (null == id) { return null; } for (ShuttleRunDirection type : ShuttleRunDirection.values()) { if (type.id.equals(id.shortValue())) { return type; } } return null; } public static ShuttleRunDirection get(ShuttleRunDirection type) { if (null == type) { return null; } for (ShuttleRunDirection shuttleRunDirection : ShuttleRunDirection.values()) { if (shuttleRunDirection == type) { return shuttleRunDirection; } } return null; } } src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
@@ -22,6 +22,16 @@ public Short taskNo = 0; /** * 源库位 */ public String sourceLocNo; /** * 目标库位 */ public String locNo; /** * 排 */ public Short row; @@ -220,4 +230,9 @@ this.busyStatusType = type; } //获取电池电量 public Short getBatteryPower() { return (short) (this.batteryPower * 0.1); } }