| | |
| | | return R.ok().add(basMap.getData()); |
| | | } |
| | | |
| | | @GetMapping("/basMap/getLevList") |
| | | @ManagerAuth |
| | | public R getLevList() { |
| | | List<Integer> levList = basMapService.getLevList(); |
| | | return R.ok().add(levList); |
| | | } |
| | | |
| | | @Autowired |
| | | private MapExcelUtils mapExcelUtils; |
| | | |
| | |
| | | |
| | | HashMap<Integer, List<List<HashMap<String, Object>>>> dataMap = mapExcelUtils.readExcel(filePath); |
| | | |
| | | List<List<HashMap<String, Object>>> dataList = new ArrayList<>(); |
| | | for (Map.Entry<Integer, List<List<HashMap<String, Object>>>> entry : dataMap.entrySet()) { |
| | | Integer key = entry.getKey(); |
| | | Integer lev = entry.getKey(); |
| | | List<List<HashMap<String, Object>>> dataList = new ArrayList<>(); |
| | | List<List<HashMap<String, Object>>> list = entry.getValue(); |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | |
| | | } |
| | | dataList.add(arrayList); |
| | | } |
| | | } |
| | | |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1)); |
| | | if (basMap == null){ |
| | | basMap = new BasMap(); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev)); |
| | | if (basMap == null){ |
| | | basMap = new BasMap(); |
| | | } |
| | | basMap.setData(JSON.toJSONString(dataList)); |
| | | basMap.setOriginData(JSON.toJSONString(dataList)); |
| | | basMap.setCreateTime(new Date()); |
| | | basMap.setUpdateTime(new Date()); |
| | | basMap.setLev(lev); |
| | | basMapService.insertOrUpdate(basMap); |
| | | } |
| | | basMap.setData(JSON.toJSONString(dataList)); |
| | | basMap.setOriginData(JSON.toJSONString(dataList)); |
| | | basMap.setCreateTime(new Date()); |
| | | basMap.setUpdateTime(new Date()); |
| | | basMapService.insertOrUpdate(basMap); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | package com.zy.asrs.service; |
| | | |
| | | import com.zy.asrs.entity.BasMap; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | public interface BasMapService extends IService<BasMap> { |
| | |
| | | |
| | | boolean deleteByLev(Integer lev);//删除指定楼层地图 |
| | | |
| | | List<Integer> getLevList();//获取所有楼层地图 |
| | | |
| | | } |
| | |
| | | import com.zy.asrs.mapper.BasMapMapper; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.service.BasMapService; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("basMapService") |
| | |
| | | return this.baseMapper.deleteByLev(lev); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getLevList() { |
| | | return this.baseMapper.selectList(new EntityWrapper<>()).stream().map(BasMap::getLev).collect(Collectors.toList()); |
| | | } |
| | | |
| | | } |
| | |
| | | //用来存放已经出现过的结点。 |
| | | Map<String, Integer> bestGMap = new HashMap<>(); |
| | | |
| | | public List<List<NavigateNode>> getStationMap() { |
| | | public List<List<NavigateNode>> getStationMap(int lev) { |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1)); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev)); |
| | | if (basMap == null) { |
| | | throw new CoolException("地图不存在"); |
| | | } |
| | |
| | | return navigateNodeList; |
| | | } |
| | | |
| | | public List<List<NavigateNode>> getRgvTrackMap() { |
| | | public List<List<NavigateNode>> getRgvTrackMap(int lev) { |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1)); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev)); |
| | | if (basMap == null) { |
| | | throw new CoolException("地图不存在"); |
| | | } |
| | |
| | | @Component |
| | | public class NavigateUtils { |
| | | |
| | | public synchronized List<NavigateNode> calcByStationId(Integer startStationId, Integer endStationId) { |
| | | public synchronized List<NavigateNode> calcByStationId(int lev, Integer startStationId, Integer endStationId) { |
| | | NavigateSolution navigateSolution = new NavigateSolution(); |
| | | List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(); |
| | | List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev); |
| | | |
| | | NavigateNode startNode = navigateSolution.findStationNavigateNode(stationMap, startStationId); |
| | | if (startNode == null){ |
| | |
| | | return fitlerList; |
| | | } |
| | | |
| | | public synchronized List<NavigateNode> calcByTrackSiteNo(Integer startTrackSiteNo, Integer endTrackSiteNo) { |
| | | public synchronized List<NavigateNode> calcByTrackSiteNo(int lev, Integer startTrackSiteNo, Integer endTrackSiteNo) { |
| | | NavigateSolution navigateSolution = new NavigateSolution(); |
| | | List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap(); |
| | | List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap(lev); |
| | | |
| | | NavigateNode startNode = navigateSolution.findTrackSiteNoNavigateNode(rgvTrackMap, startTrackSiteNo); |
| | | if (startNode == null){ |
| | |
| | | return fitlerList; |
| | | } |
| | | |
| | | public synchronized List<NavigateNode> findLiftStationList(int lev) { |
| | | NavigateSolution navigateSolution = new NavigateSolution(); |
| | | List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev); |
| | | |
| | | List<NavigateNode> liftStationList = new ArrayList<>(); |
| | | for (List<NavigateNode> navigateNodes : stationMap) { |
| | | for (NavigateNode navigateNode : navigateNodes) { |
| | | String nodeType = navigateNode.getNodeType(); |
| | | if(nodeType == null){ |
| | | continue; |
| | | } |
| | | if(!nodeType.equals("devp")){ |
| | | continue; |
| | | } |
| | | JSONObject valuObject = JSON.parseObject(navigateNode.getNodeValue()); |
| | | if(valuObject == null){ |
| | | continue; |
| | | } |
| | | if (valuObject.containsKey("liftNo")) { |
| | | liftStationList.add(navigateNode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return liftStationList; |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.service.BasMapService; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.core.enums.RgvModeType; |
| | | import com.zy.core.enums.RgvStatusType; |
| | | import com.zy.core.enums.RgvTaskModeType; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.command.RgvCommand; |
| | | import com.zy.core.network.api.ZyRgvConnectApi; |
| | | import com.zy.core.network.entity.ZyRgvStatusEntity; |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | |
| | | return; |
| | | } |
| | | |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | if (basMapService == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Integer> levList = basMapService.getLevList(); |
| | | |
| | | List<NavigateNode> navigateNodes = null; |
| | | try { |
| | | navigateNodes = navigateUtils.calcByTrackSiteNo(status.getRgvPos(), sourcePos); |
| | | for (Integer lev : levList) { |
| | | navigateNodes = navigateUtils.calcByTrackSiteNo(lev, status.getRgvPos(), sourcePos); |
| | | if (navigateNodes != null) { |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | |
| | | List<NavigateNode> targetNavigateNodes = null; |
| | | try { |
| | | targetNavigateNodes = navigateUtils.calcByTrackSiteNo(sourcePos, targetPos); |
| | | for (Integer lev : levList) { |
| | | targetNavigateNodes = navigateUtils.calcByTrackSiteNo(lev, sourcePos, targetPos); |
| | | if (targetNavigateNodes != null) { |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | if (basMapService == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Integer> levList = basMapService.getLevList(); |
| | | |
| | | List<NavigateNode> navigateNodes = null; |
| | | try { |
| | | navigateNodes = navigateUtils.calcByTrackSiteNo(status.getRgvPos(), targetPos); |
| | | for (Integer lev : levList) { |
| | | navigateNodes = navigateUtils.calcByTrackSiteNo(lev, status.getRgvPos(), targetPos); |
| | | if (navigateNodes != null) { |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | |
| | | private void handleCommand(StationCommand command) { |
| | | Integer stationId = command.getStationId(); |
| | | Integer targetStationId = command.getTargetStaNo(); |
| | | |
| | | String startLev = String.valueOf(stationId).substring(0, 1); |
| | | String endLev = String.valueOf(targetStationId).substring(0, 1); |
| | | |
| | | if (startLev.equals(endLev)) { |
| | | currentLevCommand(command); |
| | | }else { |
| | | diffLevCommand(command); |
| | | } |
| | | } |
| | | |
| | | private void currentLevCommand(StationCommand command) { |
| | | NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class); |
| | | if (navigateUtils == null) { |
| | | return; |
| | |
| | | Integer stationId = command.getStationId(); |
| | | Integer targetStationId = command.getTargetStaNo(); |
| | | |
| | | String startLev = String.valueOf(stationId).substring(0, 1); |
| | | |
| | | List<NavigateNode> navigateNodes = null; |
| | | |
| | | try { |
| | | navigateNodes = navigateUtils.calcByStationId(stationId, targetStationId); |
| | | navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationId, targetStationId); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | stationMove(navigateNodes, taskNo, targetStationId); |
| | | } |
| | | |
| | | private void diffLevCommand(StationCommand command) { |
| | | NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class); |
| | | if (navigateUtils == null) { |
| | | return; |
| | | } |
| | | |
| | | Integer taskNo = command.getTaskNo(); |
| | | Integer stationId = command.getStationId(); |
| | | Integer targetStationId = command.getTargetStaNo(); |
| | | |
| | | String startLev = String.valueOf(stationId).substring(0, 1); |
| | | String endLev = String.valueOf(targetStationId).substring(0, 1); |
| | | |
| | | List<NavigateNode> navigateNodes = null; |
| | | List<NavigateNode> targetNavigateNodes = null; |
| | | |
| | | try { |
| | | List<NavigateNode> liftStationList = navigateUtils.findLiftStationList(Integer.parseInt(startLev)); |
| | | if(liftStationList.isEmpty()){ |
| | | //未找到提升机节点 |
| | | return; |
| | | } |
| | | |
| | | List<NavigateNode> targetLiftStationList = navigateUtils.findLiftStationList(Integer.parseInt(endLev)); |
| | | if(targetLiftStationList.isEmpty()){ |
| | | //未找到提升机节点 |
| | | return; |
| | | } |
| | | for (NavigateNode liftStation : liftStationList) { |
| | | JSONObject valuObject = JSON.parseObject(liftStation.getNodeValue()); |
| | | if(valuObject == null){ |
| | | continue; |
| | | } |
| | | Integer liftStationId = valuObject.getInteger("stationId"); |
| | | Integer liftNo = valuObject.getInteger("liftNo"); |
| | | |
| | | Integer targetLiftStationId = null; |
| | | for (NavigateNode targetLiftStation : targetLiftStationList) { |
| | | JSONObject targetValuObject = JSON.parseObject(targetLiftStation.getNodeValue()); |
| | | if(targetValuObject == null){ |
| | | continue; |
| | | } |
| | | Integer targetLiftNo = targetValuObject.getInteger("liftNo"); |
| | | if(liftNo.equals(targetLiftNo)){ |
| | | targetLiftStationId = targetValuObject.getInteger("stationId"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if(targetLiftStationId == null){ |
| | | continue; |
| | | } |
| | | |
| | | navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationId, liftStationId); |
| | | if(navigateNodes == null){ |
| | | continue; |
| | | } |
| | | |
| | | //计算提升机到目标站的路径 |
| | | targetNavigateNodes = navigateUtils.calcByStationId(Integer.parseInt(endLev), targetLiftStationId, targetStationId); |
| | | if(targetNavigateNodes == null) { |
| | | continue; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (navigateNodes == null || targetNavigateNodes == null) { |
| | | return; |
| | | } |
| | | |
| | | stationMove(navigateNodes, taskNo, stationId); |
| | | stationMove(targetNavigateNodes, taskNo, targetStationId); |
| | | } |
| | | |
| | | private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId) { |
| | | Integer lastStationId = null; |
| | | for (int i = 0; i < navigateNodes.size(); i++) { |
| | | NavigateNode navigateNode = navigateNodes.get(i); |
| | |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | </div> |
| | | <div id="mapDataId" style="position: relative;" :style="{zoom: mapSettingParam.zoom / 100}"> |
| | | |
| | | <div style="position: absolute;top: 15px;left: 50%;display: flex;"> |
| | | <div v-if="levList.length > 1" v-for="(lev,index) in levList" :key="index" style="margin-right: 10px;"> |
| | | <el-button :type="currentLev == lev ? 'primary' : ''" @click="switchLev(lev)" size="mini">{{ lev }}F</el-button> |
| | | </div> |
| | | </div> |
| | | |
| | | <div id="mapDataId" style="position: relative;margin-top: 50px;" :style="{zoom: mapSettingParam.zoom / 100}"> |
| | | <table class="excel-table"> |
| | | <tr v-for="(row,index) in map" :key="index"> |
| | | <td |
| | |
| | | </div> |
| | | </td> |
| | | |
| | | <!-- <td>--> |
| | | <!-- <!– 显示行号 –>--> |
| | | <!-- <div class="item" style="background: none;color: #000;">#{{index+1}}</div>--> |
| | | <!-- </td>--> |
| | | </tr> |
| | | </table> |
| | | </div> |
| | |
| | | el: '#app', |
| | | data: { |
| | | map: [],//地图数据 |
| | | crnList: [], //堆垛机集合 |
| | | levList: [], |
| | | currentLev: 1, |
| | | systemStatus: true,//系统运行状态 |
| | | consoleInterval: null,//定时器存储变量 |
| | | crnInitPosition: [], |
| | |
| | | init() { |
| | | this.getMap() |
| | | this.getSystemRunningStatus() //获取系统运行状态 |
| | | this.getLevList() //获取地图层级列表 |
| | | |
| | | this.consoleInterval = setInterval(() => { |
| | | this.getCrnInfo() //获取堆垛机数据 |
| | |
| | | this.getRgvInfo() //获取RGV数据 |
| | | }, 1000) |
| | | }, |
| | | getLevList() { |
| | | let that = this; |
| | | $.ajax({ |
| | | url: baseUrl + "/basMap/getLevList", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | method: "get", |
| | | success: (res) => { |
| | | let data = res.data; |
| | | that.levList = data; |
| | | } |
| | | }) |
| | | }, |
| | | //获取地图数据 |
| | | getMap() { |
| | | let that = this |
| | | let rowPx = 35; |
| | | let colPx = 35; |
| | | |
| | | $.ajax({ |
| | | url: baseUrl + "/basMap/lev/1/auth", |
| | | url: baseUrl + "/basMap/lev/" + this.currentLev + "/auth", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | |
| | | col.width = (col.cellWidth / 30) + "px"; |
| | | }) |
| | | }) |
| | | this.map = mapData; |
| | | that.map = mapData; |
| | | } |
| | | }) |
| | | }, |
| | | switchLev(lev) { |
| | | this.currentLev = lev; |
| | | this.getMap() |
| | | }, |
| | | openCrn(id) { |
| | | this.crnParam.crnNo = id; |
| | |
| | | let position = [] |
| | | for (var i = 0; i < crns.length; i++) { |
| | | var crnEl = $("#crn-" + crns[i].crnId); |
| | | if(crnEl.offset() == undefined) { |
| | | continue; |
| | | } |
| | | position.push({ |
| | | id: crns[i].crnId, |
| | | left: crnEl.offset().left + crnEl.width() |
| | |
| | | crnStatus: crns[i].crnStatus |
| | | }) |
| | | } |
| | | that.crnList = crnList; |
| | | |
| | | } else if (res.code === 403) { |
| | | parent.location.href = baseUrl + "/login"; |
| | | } else { |
| | |
| | | let position = [] |
| | | for (var i = 0; i < rgvs.length; i++) { |
| | | var rgvEl = $("#rgv-" + rgvs[i].rgvNo); |
| | | if(rgvEl.offset() == undefined) { |
| | | continue; |
| | | } |
| | | position.push({ |
| | | id: rgvs[i].rgvNo, |
| | | trackSiteNo: rgvs[i].trackSiteNo, |
| | |
| | | |
| | | for (var i = 0; i < rgvs.length; i++) { |
| | | var rgvEl = $("#rgv-" + rgvs[i].rgvNo); |
| | | if (rgvs[i].rgvStatus == 'IDLE') { |
| | | if (rgvs[i].rgvStatus == 'idle') { |
| | | rgvEl.attr("class", "rgv-item"); |
| | | }else if (rgvs[i].rgvStatus == 'WORKING') { |
| | | }else if (rgvs[i].rgvStatus == 'working') { |
| | | rgvEl.attr("class", "rgv-item machine-working"); |
| | | }else if (rgvs[i].rgvStatus == 'waiting') { |
| | | rgvEl.attr("class", "rgv-item machine-working"); |
| | | }else { |
| | | rgvEl.attr("class", "rgv-item machine-un-auto"); |
| | | } |
| | | |
| | | let trackSiteNo = rgvs[i].trackSiteNo; |
| | | let trackSiteEl = $("#rgvTrackSiteNo-" + trackSiteNo); |
| | | |
| | | if(rgvEl.offsetParent().offset() == undefined) { |
| | | continue; |
| | | } |
| | | |
| | | let parentLeft = rgvEl.offsetParent().offset().left; |
| | | let targetPosition = trackSiteEl.parent().parent().offset().left - parentLeft; |
| | | let rgvPosition = rgvEl.position().left; |