src/main/java/com/zy/asrs/controller/OpenController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/asrs/controller/RgvController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/asrs/entity/BasDevpPosition.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/protocol/RgvProtocol.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/protocol/TaskProtocol.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/RgvThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/BasDevpPositionMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/webapp/views/deviceOperate/rgvOperate.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -400,7 +400,7 @@ if(Cools.isEmpty(staDesc)){ return R.error("出库路劲不存在"); } r = openService.taskCreate(new TaskCreateParam(param,staDesc.getCrnNo(),staDesc.getCrnStn())); r = openService.taskCreate(new TaskCreateParam(param,staDesc.getCrnNo(),staDesc.getStnNo())); }else if (param.getIoType() == 3){ LocMast locMast2 = locMastService.selectByLocNo(param.getTargetPoint()); if(Cools.isEmpty(locMast2)){ src/main/java/com/zy/asrs/controller/RgvController.java
New file @@ -0,0 +1,188 @@ package com.zy.asrs.controller; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.annotations.ManagerAuth; import com.core.common.R; import com.zy.asrs.entity.BasDevpPosition; import com.zy.asrs.service.BasDevpPositionService; import com.zy.core.cache.RgvStatusCache; import com.zy.core.cache.SlaveConnection; import com.zy.core.cache.TaskProtocolCache; import com.zy.core.enums.SlaveType; import com.zy.core.model.protocol.RgvProtocol; import com.zy.core.model.protocol.TaskProtocol; import com.zy.core.thread.RgvThread; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * 输送设备接口 * Created by vincent on 2020-06-01 */ @RestController @RequestMapping("/rgv") public class RgvController { @Autowired private BasDevpPositionService basDevpPositionService; @GetMapping("/status/all") @ManagerAuth(memo = "全部信息") public R allStatus(){ List<Map<String, Object>> res = new ArrayList<>(); ConcurrentHashMap<Integer, RgvProtocol> allRgvStatus = RgvStatusCache.getAllRgvStatus(); for (RgvProtocol rgvProtocol : allRgvStatus.values()){ Map<String, Object> map2 = new HashMap<>(); map2.put("rgvNo", rgvProtocol.getRgvNo()); map2.put("taskNo", rgvProtocol.getTaskNo()); map2.put("mode", rgvProtocol.getModeType().desc); map2.put("status", rgvProtocol.getStatusType().desc); map2.put("rgvPos", rgvProtocol.getRgvPos()); map2.put("rgvPosDestination", rgvProtocol.getRgvPosDestination()); map2.put("loaded", rgvProtocol.getLoaded().equals((short)-1)? "未知":rgvProtocol.getLoaded()==1? "有物":"无物"); res.add(map2); } return R.ok().add(res); } @PostMapping("/run/walk")//Take Put Walk @ManagerAuth(memo = "小车行走") public R rgvRunWalk(@RequestParam Integer rgvNo, @RequestParam Integer taskNo, @RequestParam Integer rgvStaNo, @RequestParam Long rgvPosDestination ) { if (rgvNo==null || rgvNo==0){ return R.error("请选择小车"); } if (taskNo==null || taskNo==0){ return R.error("作业号请填写"); } if ((rgvStaNo == null || rgvStaNo == 0) && (rgvPosDestination==null || rgvPosDestination==0L)){ return R.error("目标站点请填写"); } if (rgvPosDestination == null || rgvPosDestination == 0){ BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNo)); rgvPosDestination = basDevpPosition.getPlcPosition(); } RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo); TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache(); TaskProtocol issued = new TaskProtocol(); try { ConcurrentHashMap<String, TaskProtocol> allTaskProtocol = taskProtocolCache.getAllTaskProtocol(); if (allTaskProtocol.size() > 0) { return R.error("存在执行中任务,请先处理!!!"); } //执行 issued.setTaskNo(Long.valueOf(taskNo)); issued.setTaskStatus(1); issued.setTaskNoDirection(issued.gettaskNoDirection$(issued.getTaskNo(), issued.getTaskStatus())); issued.setTargetPosition(rgvPosDestination); issued.setIsRunning(1); issued.setDirection(true); taskProtocolCache.updateTaskProtocol(issued); } catch (Exception e) { return R.error("任务生成失败"+e.getMessage()); } return R.ok("任务生成成功"); } @PostMapping("/run/put")//Take Put Walk @ManagerAuth(memo = "小车放货") public R rgvPutWalk(@RequestParam Integer rgvNo, @RequestParam Integer taskNo, @RequestParam Integer rgvStaNo, @RequestParam Long rgvPosDestination ) { if (rgvNo==null || rgvNo==0){ return R.error("请选择小车"); } if (taskNo==null || taskNo==0){ return R.error("作业号请填写"); } if (rgvStaNo == null || rgvStaNo == 0){ return R.error("目标站点请填写"); } RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo); TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache(); TaskProtocol issuedPut = new TaskProtocol(); try { ConcurrentHashMap<String, TaskProtocol> allTaskProtocol = taskProtocolCache.getAllTaskProtocol(); if (allTaskProtocol.size() > 0) { return R.error("存在执行中任务,请先处理!!!"); } BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNo)); //执行 issuedPut.setTaskNo(Long.valueOf(taskNo)); issuedPut.setTaskStatus(3); issuedPut.setTaskNoDirection(issuedPut.gettaskNoDirection$(issuedPut.getTaskNo(), issuedPut.getTaskStatus())); issuedPut.setTargetPosition(basDevpPosition.getPlcPosition()); issuedPut.setIsRunning(1); issuedPut.setDirection(basDevpPosition.getRgvSign()==1); taskProtocolCache.updateTaskProtocol(issuedPut); } catch (Exception e) { return R.error("任务生成失败"+e.getMessage()); } return R.ok("任务生成成功"); } @PostMapping("/run/take")//Take Put Walk @ManagerAuth(memo = "小车取货") public R rgvTakeWalk(@RequestParam Integer rgvNo, @RequestParam Integer taskNo, @RequestParam Integer rgvStaNo, @RequestParam Long rgvPosDestination ) { if (rgvNo==null || rgvNo==0){ return R.error("请选择小车"); } if (taskNo==null || taskNo==0){ return R.error("作业号请填写"); } if (rgvStaNo == null || rgvStaNo == 0){ return R.error("目标站点请填写"); } RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo); TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache(); TaskProtocol issuedTake = new TaskProtocol(); try { ConcurrentHashMap<String, TaskProtocol> allTaskProtocol = taskProtocolCache.getAllTaskProtocol(); if (allTaskProtocol.size() > 0) { return R.error("存在执行中任务,请先处理!!!"); } BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNo)); //执行 issuedTake.setTaskNo(Long.valueOf(taskNo)); issuedTake.setTaskStatus(2); issuedTake.setTaskNoDirection(issuedTake.gettaskNoDirection$(issuedTake.getTaskNo(), issuedTake.getTaskStatus())); issuedTake.setTargetPosition(basDevpPosition.getPlcPosition()); issuedTake.setIsRunning(1); issuedTake.setDirection(basDevpPosition.getRgvSign()==1); taskProtocolCache.updateTaskProtocol(issuedTake); } catch (Exception e) { return R.error("任务生成失败"+e.getMessage()); } return R.ok("任务生成成功"); } } src/main/java/com/zy/asrs/entity/BasDevpPosition.java
@@ -34,6 +34,10 @@ @TableField("PLC_POSITION") private Long plcPosition; @ApiModelProperty(value= "") @TableField("RGV_SIGN") private Integer rgvSign; public BasDevpPosition() {} public BasDevpPosition(Integer devNo, Integer plcId, Long plcPosition) { src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1612,10 +1612,6 @@ if (targetPointConvert == null) { return false; } RgvSlave.RgvStn rgvStnEnd = getRgvStnNow(rgvSlave, targetPointConvert); if (rgvStnEnd == null) { return false; } BasDevpPosition basDevpPositionSou = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStn.getStaNo())); BasDevpPosition basDevpPositionEnd = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", targetPointConvert)); @@ -1625,7 +1621,7 @@ issuedTake.setTaskNoDirection(issuedTake.gettaskNoDirection$(issuedTake.getTaskNo(), issuedTake.getTaskStatus())); issuedTake.setTargetPosition(basDevpPositionSou.getPlcPosition()); issuedTake.setIsRunning(1); issuedTake.setDirection(rgvStn.isDirection()); issuedTake.setDirection(basDevpPositionSou.getRgvSign()==1); issuedPut.setTaskNo(Long.valueOf(taskWrk.getTaskNo())); @@ -1633,7 +1629,7 @@ issuedPut.setTaskNoDirection(issuedPut.gettaskNoDirection$(issuedPut.getTaskNo(), issuedPut.getTaskStatus())); issuedPut.setTargetPosition(basDevpPositionEnd.getPlcPosition()); issuedPut.setIsRunning(1); issuedPut.setDirection(rgvStnEnd.isDirection()); issuedPut.setDirection(basDevpPositionEnd.getRgvSign()==1); } catch (Exception e) { log.error("任务生成失败issued1===》异常信息:{}", e.getMessage()); return false; src/main/java/com/zy/core/model/protocol/RgvProtocol.java
@@ -43,7 +43,7 @@ /** * 有物 */ public Short loaded;//0 无物;1 有物 public Short loaded = -1;//0 无物;1 有物 /** * RGV当前位置 src/main/java/com/zy/core/model/protocol/TaskProtocol.java
@@ -47,10 +47,10 @@ public String gettaskNoDirection$(Long taskNo,int taskStatus){ String taskStatusStr = "Walk"; switch (taskStatus){ case 1: case 2: taskStatusStr = "Tack"; break; case 2: case 3: taskStatusStr = "Put"; break; } src/main/java/com/zy/core/thread/RgvThread.java
@@ -81,6 +81,7 @@ // 启动漫游线程 new Thread(this::taskWalkIssued).start(); new Thread(this::taskWalkIssued2).start(); // 启动任务完成线程 new Thread(this::taskComplete).start(); @@ -127,6 +128,64 @@ } /** * 任务下发 */ private void taskWalkIssued2() { while (true) { try { // 休眠 1 秒 Thread.sleep(100); if (!deviceDetection()) { continue; } RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); if (rgvProtocol == null || rgvTaskProtocol == null) { initRgv(); rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); } if (rgvTaskProtocol.getAvoid() != 0) { continue; } if (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE)){ continue; } if (rgvProtocol.getLoaded() == -1){ continue; } List<TaskProtocol> allTakeTaskProtocol = taskProtocolCache.getAllWalkTaskProtocol(); for (TaskProtocol taskProtocol : allTakeTaskProtocol) { if (taskProtocol.getIsRunning() == 1) {//准备下发 // 双车 if (rgvOtherStatusEnable()) { //另一台车是否允许此台车执行 if (!otherRgvAvoid(taskProtocol.getTargetPosition())) { continue; } } if (taskProtocol.getTargetPosition()<=rgvProtocol.getRgvPos()+50 && taskProtocol.getTargetPosition()>=rgvProtocol.getRgvPos()-50){ taskProtocolCache.removeTaskProtocol(taskProtocol.getTaskNoDirection()); break; } else { Thread.sleep(100); TaskProtocol issued = new TaskProtocol(taskProtocol,true); write(issued); taskProtocolCache.removeTaskProtocol(taskProtocol.getTaskNoDirection()); break; } } } } catch (Exception e) { log.error("RGV取货任务下发线程异常!!!" + e.getMessage()); // e.printStackTrace(); } } } /** * 漫游 */ private void taskWalkIssued() { @@ -149,6 +208,8 @@ TaskProtocol issued = new TaskProtocol(); issued.setTaskNo(32222L); issued.setTargetPosition(rgvTaskProtocol.getAvoidingTheDestination()); issued.setTaskStatus(1); issued.setDirection(true); write(issued); rgvTaskProtocol.setAvoid(0); @@ -186,11 +247,14 @@ if (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE)){ continue; } if (rgvProtocol.getLoaded() == -1){ continue; } List<TaskProtocol> allTakeTaskProtocol = taskProtocolCache.getTakeOrPutTaskProtocol(rgvProtocol.getLoaded()); for (TaskProtocol taskProtocol : allTakeTaskProtocol) { if (taskProtocol.getIsRunning() == 1) {//准备下发 RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); // RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); //双车 if (rgvOtherStatusEnable()) { //另一台车是否允许此台车执行 @@ -203,16 +267,12 @@ Thread.sleep(100); TaskProtocol issued = new TaskProtocol(taskProtocol); write(issued); // taskProtocol.setIsRunning(4); // taskProtocolCache.updateTaskProtocol(taskProtocol); taskProtocolCache.removeTaskProtocol(taskProtocol.getTaskNoDirection()); break; } else { Thread.sleep(100); TaskProtocol issued = new TaskProtocol(taskProtocol,true); write(issued); // taskProtocol.setIsRunning(4); // taskProtocolCache.updateTaskProtocol(taskProtocol); break; } } src/main/resources/mapper/BasDevpPositionMapper.xml
@@ -8,6 +8,7 @@ <result column="DEV_NO" property="devNo" /> <result column="PLC_ID" property="plcId" /> <result column="PLC_POSITION" property="plcPosition" /> <result column="RGV_SIGN" property="rgvSign" /> </resultMap> src/main/webapp/views/deviceOperate/rgvOperate.html
@@ -16,13 +16,19 @@ <div style="width: 100%;"> <el-table ref="singleTable" :data="tableData" highlight-current-row @row-click="handleRowClick" max-height="450" style="width: 100%"> <el-table-column property="devNo" label="小车号"> <el-table-column property="rgvNo" label="小车号"> </el-table-column> <el-table-column property="workNo" label="工作号"> <el-table-column property="taskNo" label="工作号"> </el-table-column> <el-table-column property="locType1" label="高低库位"> <el-table-column property="mode" label="作业模式"> </el-table-column> <el-table-column property="pakMk" label="入库标记"> <el-table-column property="status" label="状态"> </el-table-column> <el-table-column property="rgvPos" label="当前定位值"> </el-table-column> <el-table-column property="rgvPosDestination" label="目标定位置"> </el-table-column> <el-table-column property="loaded" label="有物"> </el-table-column> </el-table> </div> @@ -36,27 +42,19 @@ <div> <el-form :model="formParam" label-position="top" :inline="true" class="demo-form-inline"> <el-form-item label="工作号"> <el-input v-model="formParam.workNo" placeholder="工作号"></el-input> <el-input v-model="formParam.taskNo" placeholder="工作号"></el-input> </el-form-item> <el-form-item label="目标站"> <el-input v-model="formParam.staNo" placeholder="目标站"></el-input> <el-form-item label="目标定位置"> <el-input v-model="formParam.rgvPosDestination" placeholder="目标定位置"></el-input> </el-form-item> <el-form-item label="入库标记"> <el-input v-model="formParam.pakMk" placeholder="入库标记"></el-input> </el-form-item> </el-form> <el-form label-position="top" :inline="true" class="demo-form-inline"> <el-form-item label=""> <el-checkbox v-model="formParam.inEnable">可入</el-checkbox> </el-form-item> <el-form-item label=""> <el-checkbox v-model="formParam.outEnable">可出</el-checkbox> <el-form-item label="目标站点"> <el-input v-model="formParam.rgvStaNo" placeholder="目标站点"></el-input> </el-form-item> </el-form> <div> <el-button @click="requestOperate('update')" type="primary">更新</el-button> <el-button @click="requestOperate('out')" type="warning">取货完成</el-button> <el-button @click="requestOperate('in')" type="warning">放货完成</el-button> <el-button @click="requestOperate('take')" type="primary">取货</el-button> <el-button @click="requestOperate('put')" type="primary">放货</el-button> <el-button @click="requestOperate('walk')" type="warning">行走</el-button> </div> </div> </el-card> @@ -109,12 +107,10 @@ currentTitle: "未选择设备", currentIndex: null, formParam: { devNo: null, workNo: null, staNo: null, pakMk: null, inEnable: false, outEnable: false rgvNo: 0, taskNo: 0, rgvStaNo: 0, rgvPosDestination: 0 } }, created() { @@ -135,19 +131,17 @@ const index = this.tableData.indexOf(row) this.currentRow = row; this.currentIndex = index this.currentTitle = row.devNo + "站点" this.currentTitle = row.rgvNo + "小车" this.formParam.devNo = row.devNo this.formParam.workNo = row.workNo this.formParam.staNo = row.staNo this.formParam.pakMk = row.pakMk this.formParam.inEnable = row.inEnable == "Y" ? true : false this.formParam.outEnable = row.outEnable == "Y" ? true : false this.formParam.rgvNo = row.rgvNo this.formParam.taskNo = row.taskNo this.formParam.rgvStaNo = row.rgvStaNo this.formParam.rgvPosDestination = row.rgvPosDestination }, getTableData() { let that = this; $.ajax({ url: baseUrl + "/site/list/auth", url: baseUrl + "/rgv/status/all", headers: { 'token': localStorage.getItem('token') }, @@ -168,7 +162,7 @@ type: 'warning' }).then(()=>{ $.ajax({ url: baseUrl + "/site/detl/"+method, url: baseUrl + "/rgv/run/"+method, headers: { 'token': localStorage.getItem('token') },