|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.BasShuttle; | 
|---|
|  |  |  | import com.zy.asrs.entity.LocMast; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.mapper.WrkMastMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.BasShuttleService; | 
|---|
|  |  |  | import com.zy.asrs.service.LocMastService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.asrs.service.impl.MainServiceImpl; | 
|---|
|  |  |  | import com.zy.common.model.NavigateNode; | 
|---|
|  |  |  | import com.zy.common.model.enums.NavigationMapType; | 
|---|
|  |  |  | import com.zy.common.service.CommonService; | 
|---|
|  |  |  | import com.zy.common.utils.NavigateMapData; | 
|---|
|  |  |  | import com.zy.common.utils.NavigatePositionConvert; | 
|---|
|  |  |  | import com.zy.common.utils.NavigateUtils; | 
|---|
|  |  |  | import com.zy.common.utils.ShuttleDispatchUtils; | 
|---|
|  |  |  | import com.zy.core.DevpThread; | 
|---|
|  |  |  | import com.zy.core.Slave; | 
|---|
|  |  |  | import com.zy.core.cache.MessageQueue; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.ShuttleRunDirection; | 
|---|
|  |  |  | import com.zy.core.enums.ShuttleTaskModeType; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.DevpSlave; | 
|---|
|  |  |  | import com.zy.core.model.ShuttleSlave; | 
|---|
|  |  |  | import com.zy.core.model.Task; | 
|---|
|  |  |  | import com.zy.core.model.command.ShuttleAssignCommand; | 
|---|
|  |  |  | import com.zy.core.model.command.ShuttleCommand; | 
|---|
|  |  |  | import com.zy.core.model.protocol.NyShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.ShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.StaProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import com.zy.core.thread.NyShuttleThread; | 
|---|
|  |  |  | import com.zy.core.thread.ShuttleThread; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.text.DecimalFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.regex.Pattern; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 2020/8/27 | 
|---|
|  |  |  | 
|---|
|  |  |  | WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); | 
|---|
|  |  |  | CommonService commonService = SpringUtils.getBean(CommonService.class); | 
|---|
|  |  |  | ShuttleDispatchUtils shuttleDispatchUtils = SpringUtils.getBean(ShuttleDispatchUtils.class); | 
|---|
|  |  |  | NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (shuttleThread == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NavigateMapData mapData = new NavigateMapData(z);//获取地图数据 | 
|---|
|  |  |  | int[][] data = mapData.getData(-1, null, currentShuttleId == null ? null : Utils.getShuttlePoints(0, z));//载入全部车辆 | 
|---|
|  |  |  | navigateMapData.setLev(z);//获取地图数据 | 
|---|
|  |  |  | int[][] data = navigateMapData.getData(-1, null, currentShuttleId == null ? null : Utils.getShuttlePoints(0, z));//载入全部车辆 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int moveBay = 23;//避让起始列 | 
|---|
|  |  |  | int bay = Utils.getBay(shuttleProtocol.getCurrentLocNo());//小车当前列 | 
|---|
|  |  |  | if (bay > 1 && bay <= 30) { | 
|---|
|  |  |  | moveBay = 23; | 
|---|
|  |  |  | } else if (bay > 30 && bay <= 45) { | 
|---|
|  |  |  | moveBay = 39; | 
|---|
|  |  |  | } else if (bay > 45) { | 
|---|
|  |  |  | moveBay = 50; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int distY = -1; | 
|---|
|  |  |  | int distX = -1; | 
|---|
|  |  |  | int distZ = -1; | 
|---|
|  |  |  | //获取避让库位 | 
|---|
|  |  |  | String distLocNo = null; | 
|---|
|  |  |  | for (int y = 20; y <= 56; y++) { | 
|---|
|  |  |  | for (int y = moveBay; y <= 56; y++) { | 
|---|
|  |  |  | boolean searchFlag = true; | 
|---|
|  |  |  | for (int x = 10; x <= 11; x++) { | 
|---|
|  |  |  | if (data[x][y] < 0 || data[x][y] == 66) { | 
|---|
|  |  |  | 
|---|
|  |  |  | LocMast distLocMast = locMastService.queryByLoc(locNo); | 
|---|
|  |  |  | if (distLocMast == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (distLocMast.getLocSts().equals("X")) { | 
|---|
|  |  |  | continue;//调过禁用库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断该库位是否存在工作档 | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new RuntimeException("库位解析异常"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 通过入库站点号获取条码器ID | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Integer getBarcodeIdByStaNo(int staNo) { | 
|---|
|  |  |  | SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); | 
|---|
|  |  |  | for (DevpSlave devpSlave : slaveProperties.getDevp()) { | 
|---|
|  |  |  | for (DevpSlave.Sta sta : devpSlave.getInSta()) { | 
|---|
|  |  |  | if (sta.getStaNo().equals(staNo)) { | 
|---|
|  |  |  | return sta.getBarcode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 判断字符串是否为JSON格式 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean isJson(String jsonString) { | 
|---|
|  |  |  | // JSON格式的正则表达式 | 
|---|
|  |  |  | String pattern = "^\\{.*\\}$"; | 
|---|
|  |  |  | // 使用Pattern类进行正则匹配 | 
|---|
|  |  |  | return Pattern.matches(pattern, jsonString); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|