Commit 973cb17c authored by wanghao's avatar wanghao

1 上下料优先级调整

parent aba8c3ce
...@@ -111,6 +111,8 @@ public class RobotArmCommandController extends BaseController ...@@ -111,6 +111,8 @@ public class RobotArmCommandController extends BaseController
} }
/** /**
* 修改机械臂指令 * 修改机械臂指令
*/ */
...@@ -120,6 +122,14 @@ public class RobotArmCommandController extends BaseController ...@@ -120,6 +122,14 @@ public class RobotArmCommandController extends BaseController
return toAjax(robotArmCommandService.updateRobotArmCommand(robotArmCommand)); return toAjax(robotArmCommandService.updateRobotArmCommand(robotArmCommand));
} }
/**
* 修改指令执行优先级
*/
@GetMapping("/updateInstructionExecutionPriority/{priority}")
public AjaxResult updateInstructionExecutionPriority(@PathVariable("priority") String priority) {
return toAjax(robotArmCommandService.updateInstructionExecutionPriority(priority));
}
/** /**
* 删除机械臂指令 * 删除机械臂指令
*/ */
......
...@@ -59,6 +59,8 @@ public interface IRobotArmCommandService ...@@ -59,6 +59,8 @@ public interface IRobotArmCommandService
*/ */
public int updateRobotArmCommand(RobotArmCommand robotArmCommand); public int updateRobotArmCommand(RobotArmCommand robotArmCommand);
public int updateInstructionExecutionPriority(String priority);
/** /**
* 批量删除机械臂指令 * 批量删除机械臂指令
* *
......
...@@ -11,6 +11,7 @@ import com.serotonin.modbus4j.ModbusMaster; ...@@ -11,6 +11,7 @@ import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException; import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException; import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.zehong.common.core.domain.AjaxResult; import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.redis.RedisCache;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils; import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TEquipmentInfo; import com.zehong.system.domain.TEquipmentInfo;
...@@ -25,6 +26,7 @@ import com.zehong.system.task.PowerOffCommandEvent; ...@@ -25,6 +26,7 @@ import com.zehong.system.task.PowerOffCommandEvent;
import com.zehong.system.udp.UdpCommandSender; import com.zehong.system.udp.UdpCommandSender;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -75,6 +77,8 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -75,6 +77,8 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
@Resource @Resource
private PalletDeviceBindingMapper palletDeviceBindingMapper; private PalletDeviceBindingMapper palletDeviceBindingMapper;
@Resource
private RedisCache redisCache;
private SocketAddress getRobotAddress() { private SocketAddress getRobotAddress() {
try { try {
return new InetSocketAddress( return new InetSocketAddress(
...@@ -87,11 +91,17 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -87,11 +91,17 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
@Override @Override
@Transactional @Transactional
public void processPendingCommands() { public void processPendingCommands() {
Object cacheObject = redisCache.getCacheObject("sys_config:robotArmPriority");
String priority = "loading";
if (cacheObject != null) {
priority = (String) cacheObject;
}
// 1. 处理待执行的上料指令 // 1. 处理待执行的上料指令
List<RobotArmCommand> loadingCommands = List<RobotArmCommand> loadingCommands =
robotArmCommandMapper.selectPendingLoadingCommands(); robotArmCommandMapper.selectPendingLoadingCommands();
if (!loadingCommands.isEmpty()) { if (!loadingCommands.isEmpty() && "priority".equals(priority)) {
// 传送带检测先去掉 // 传送带检测先去掉
boolean[] roboticArmEntryConveyorData = Modbus4jUtils.getRoboticArmEntryConveyorData(); boolean[] roboticArmEntryConveyorData = Modbus4jUtils.getRoboticArmEntryConveyorData();
log.info("机械臂入口 conveyor 0状态: " + roboticArmEntryConveyorData[0]); log.info("机械臂入口 conveyor 0状态: " + roboticArmEntryConveyorData[0]);
log.info("机械臂入口 conveyor 1状态: " + roboticArmEntryConveyorData[1]); log.info("机械臂入口 conveyor 1状态: " + roboticArmEntryConveyorData[1]);
...@@ -99,15 +109,12 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -99,15 +109,12 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
sendCommand(loadingCommands.get(0), "LOAD"); sendCommand(loadingCommands.get(0), "LOAD");
return; return;
} }
// log.info("开始处理上料指令: {}", loadingCommands.get(0));
// sendCommand(loadingCommands.get(0), "LOAD");
} }
// 2. 处理待执行的下料指令 // 2. 处理待执行的下料指令
List<RobotArmCommand> unloadingCommands = List<RobotArmCommand> unloadingCommands =
robotArmCommandMapper.selectPendingUnloadingCommands(); robotArmCommandMapper.selectPendingUnloadingCommands();
if (!unloadingCommands.isEmpty()) { if (!unloadingCommands.isEmpty() && "unloading".equals(priority)) {
boolean[] roboticArmExitConveyorData = Modbus4jUtils.getRoboticArmExitConveyorData(); boolean[] roboticArmExitConveyorData = Modbus4jUtils.getRoboticArmExitConveyorData();
if(roboticArmExitConveyorData[1]) { if(roboticArmExitConveyorData[1]) {
log.info("开始处理下料指令: {}", unloadingCommands.get(0)); log.info("开始处理下料指令: {}", unloadingCommands.get(0));
...@@ -525,6 +532,20 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -525,6 +532,20 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
return i; return i;
} }
/**
* 修改指令执行优先级
*
* @param priority 优先级
* @return 结果
*/
@Override
public int updateInstructionExecutionPriority(String priority) {
redisCache.setCacheObject("sys_config:robotArmPriority", priority);
return 1;
}
/** /**
* 批量删除机械臂指令 * 批量删除机械臂指令
* *
......
...@@ -80,6 +80,13 @@ export function sureCompletedCommand(commandId) { ...@@ -80,6 +80,13 @@ export function sureCompletedCommand(commandId) {
}) })
} }
export function updateInstructionExecutionPriority(priority) {
return request({
url: '/robotArm/command/updateInstructionExecutionPriority/' + priority,
method: 'get'
})
}
// 修改机械臂指令 // 修改机械臂指令
export function updateCommand(data) { export function updateCommand(data) {
return request({ return request({
......
...@@ -79,6 +79,14 @@ ...@@ -79,6 +79,14 @@
<!-- 中间:机械臂主体 --> <!-- 中间:机械臂主体 -->
<div class="arm-center-wrapper"> <div class="arm-center-wrapper">
<!-- 优先级控制区域 -->
<div class="priority-control">
<div class="priority-display">{{ priorityDisplayText }}</div>
<button class="priority-toggle-btn" @click="togglePriority">
{{ priorityToggleText }}
</button>
</div>
<div class="robotic-arm-container"> <div class="robotic-arm-container">
<div class="robotic-arm"> <div class="robotic-arm">
<!-- 机械臂各部件 --> <!-- 机械臂各部件 -->
...@@ -127,7 +135,6 @@ ...@@ -127,7 +135,6 @@
</div> </div>
</div> </div>
<!-- 上电对话框 --> <!-- 上电对话框 -->
<div class="dialog-mask" v-if="showPowerOnDialog" @click.self="closePowerOnDialog"> <div class="dialog-mask" v-if="showPowerOnDialog" @click.self="closePowerOnDialog">
<div class="dialog-container"> <div class="dialog-container">
...@@ -171,8 +178,7 @@ ...@@ -171,8 +178,7 @@
</template> </template>
<script> <script>
import {addCommand,powerOnCommand,sendHomeCommand,sendStopCommand,sureCompletedCommand,updateInstructionExecutionPriority} from "@/api/robotArm/robotArmCommand"
import {addCommand,powerOnCommand,sendHomeCommand,sendStopCommand,sureCompletedCommand} from "@/api/robotArm/robotArmCommand"
export default { export default {
name: 'RoboticArm', name: 'RoboticArm',
...@@ -181,15 +187,14 @@ export default { ...@@ -181,15 +187,14 @@ export default {
status: 'idle', // idle, running, error status: 'idle', // idle, running, error
showAddDialog: false, showAddDialog: false,
trayCode: '', trayCode: '',
loadingCommands: [ loadingCommands: [],
], unloadingCommands: [],
unloadingCommands: [
],
websocket: null, websocket: null,
reconnectInterval: null, reconnectInterval: null,
showPowerOnDialog: false, showPowerOnDialog: false,
showSureCompleteDialog: false, showSureCompleteDialog: false,
selectedCommand: null selectedCommand: null,
priority: 'loading' // loading: 上料优先, unloading: 下料优先
}; };
}, },
computed: { computed: {
...@@ -208,6 +213,12 @@ export default { ...@@ -208,6 +213,12 @@ export default {
'error': '故障', 'error': '故障',
'unknown': '未知' 'unknown': '未知'
}[this.status]; }[this.status];
},
priorityDisplayText() {
return this.priority === 'loading' ? '上料优先中' : '下料优先中';
},
priorityToggleText() {
return this.priority === 'loading' ? '下料优先' : '上料优先';
} }
}, },
mounted() { mounted() {
...@@ -432,6 +443,20 @@ export default { ...@@ -432,6 +443,20 @@ export default {
this.msgError("上电操作失败"); this.msgError("上电操作失败");
}); });
}, },
// 切换优先级
togglePriority() {
this.priority = this.priority === 'loading' ? 'unloading' : 'loading';
updateInstructionExecutionPriority(this.priority).then(res => {
if(res.code === 200) {
this.msgSuccess("优先级设置成功");
} else {
this.msgError("优先级设置失败");
}
})
// 这里可以添加发送优先级设置到后端的逻辑
console.log(`优先级已切换为: ${this.priorityDisplayText} : this.priority:${this.priority}` );
}
} }
}; };
</script> </script>
...@@ -457,7 +482,7 @@ export default { ...@@ -457,7 +482,7 @@ export default {
.title-with-status { .title-with-status {
display: flex; display: flex;
align-items: center; /* 垂直居中对齐 */ align-items: center; /* 垂直居中对齐 */
gap: 15px; /* 标题与状态指示灯之间的间距 */ gap: 5px; /* 标题与状态指示灯之间的间距 */
} }
.title-left { .title-left {
...@@ -466,7 +491,7 @@ export default { ...@@ -466,7 +491,7 @@ export default {
} }
.title-text { .title-text {
font-size: 22px; font-size: 20px;
font-weight: bold; font-weight: bold;
color: #ffffff; color: #ffffff;
letter-spacing: 1px; letter-spacing: 1px;
...@@ -475,7 +500,7 @@ export default { ...@@ -475,7 +500,7 @@ export default {
.title-line { .title-line {
height: 3px; height: 3px;
width: 100px; width: 70px;
background: linear-gradient(to right, #409EFF, transparent); background: linear-gradient(to right, #409EFF, transparent);
margin-top: 8px; margin-top: 8px;
border-radius: 2px; border-radius: 2px;
...@@ -752,11 +777,52 @@ export default { ...@@ -752,11 +777,52 @@ export default {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
display: flex; display: flex;
justify-content: center; flex-direction: column;
justify-content: flex-start;
align-items: center; align-items: center;
padding: 10px 0; padding: 10px 0;
} }
/* 优先级控制区域样式 */
.priority-control {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
/*background: rgba(0, 30, 60, 0.5);*/
/*border-radius: 8px;*/
padding: 12px 20px;
/*border: 1px solid rgba(64, 158, 255, 0.3);*/
min-width: 200px;
}
.priority-display {
font-size: 16px;
font-weight: bold;
color: #64c8ff;
margin-bottom: 8px;
text-align: center;
}
.priority-toggle-btn {
background: linear-gradient(to right, #409EFF, #64c8ff);
color: white;
border: none;
padding: 6px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
font-weight: bold;
transition: all 0.3s;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.priority-toggle-btn:hover {
background: linear-gradient(to right, #64c8ff, #409EFF);
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}
.robotic-arm-container { .robotic-arm-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -1018,6 +1084,7 @@ export default { ...@@ -1018,6 +1084,7 @@ export default {
.arm-center-wrapper { .arm-center-wrapper {
width: 100%; width: 100%;
min-height: 350px; min-height: 350px;
order: -1; /* 在移动设备上将机械臂区域放在最上面 */
} }
.loading-command, .unloading-command { .loading-command, .unloading-command {
...@@ -1072,6 +1139,21 @@ export default { ...@@ -1072,6 +1139,21 @@ export default {
.dialog-container { .dialog-container {
width: 90%; width: 90%;
} }
/* 小屏幕下优先级控制区域调整 */
.priority-control {
padding: 8px 15px;
min-width: 180px;
}
.priority-display {
font-size: 14px;
}
.priority-toggle-btn {
padding: 5px 12px;
font-size: 12px;
}
} }
@media (max-width: 300px) { @media (max-width: 300px) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment