添加调度按钮,修改顶部国际化

This commit is contained in:
liuhanqing
2025-08-28 09:44:42 +08:00
parent 865be3278e
commit a5bda35055
10 changed files with 228 additions and 17 deletions

View File

@@ -63,4 +63,13 @@ public class ThreadOperationController {
scheduleThread.stopAllThread2(); scheduleThread.stopAllThread2();
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 获取调度状态
* @return
*/
@RequestMapping("/getScheduleStatus")
public AjaxResult getScheduleStatus() {
return AjaxResult.success(scheduleThread.getScheduleStatus());
}
} }

View File

@@ -12,14 +12,17 @@ import com.ruoyi.schedule.scheduleTask.ssj.js.JsInSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.js.JsOutSsjThread; import com.ruoyi.schedule.scheduleTask.ssj.js.JsOutSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.js.JsPickSsjTread; import com.ruoyi.schedule.scheduleTask.ssj.js.JsPickSsjTread;
import com.ruoyi.schedule.scheduleTask.ssj.monitor.SsjMonitorThread; import com.ruoyi.schedule.scheduleTask.ssj.monitor.SsjMonitorThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Component @Component
@Slf4j
public class ScheduleThread { public class ScheduleThread {
public CustomThread<PlcRead> customThread; public CustomThread<PlcRead> customThread;
@@ -34,16 +37,21 @@ public class ScheduleThread {
public CustomThread<JsPickSsjTread> jsPickSsjThread; public CustomThread<JsPickSsjTread> jsPickSsjThread;
public CustomThread<SsjMonitorThread> ssjMonitorThread; public CustomThread<SsjMonitorThread> ssjMonitorThread;
private boolean isRun = false;
private boolean isRun2 = false;
/** /**
* 项目初始化启动 * 项目初始化启动
*/ */
@PostConstruct @PostConstruct
public void init() { public void init() {
log.info("初始化调度服务");
//读取信息初始化 //读取信息初始化
plcReadInit(); plcReadInit();
//调度初始化 //调度初始化
scheduleInit(); scheduleInit();
log.info("调度服务执行成功");
} }
/** /**
@@ -92,6 +100,7 @@ public class ScheduleThread {
*/ */
public void startAllThread() { public void startAllThread() {
customThread.getThread().start(); customThread.getThread().start();
isRun = true;
} }
/** /**
@@ -113,6 +122,8 @@ public class ScheduleThread {
//jsPickSsjThread.getThread().start(); //jsPickSsjThread.getThread().start();
//监控输送机 //监控输送机
//ssjMonitorThread.getThread().start(); //ssjMonitorThread.getThread().start();
isRun2 = true;
} }
/** /**
@@ -121,6 +132,7 @@ public class ScheduleThread {
public void stopAllThread() { public void stopAllThread() {
customThread.runnable.isRun = false; customThread.runnable.isRun = false;
plcReadInit(); plcReadInit();
isRun = false;
} }
/** /**
@@ -134,7 +146,16 @@ public class ScheduleThread {
bsPickSsjThread.runnable.isRun = false; bsPickSsjThread.runnable.isRun = false;
jsPickSsjThread.runnable.isRun = false; jsPickSsjThread.runnable.isRun = false;
scheduleInit(); scheduleInit();
isRun2 = false;
} }
/**
* 获取调度状态
*/
public HashMap<String,Boolean> getScheduleStatus() {
HashMap<String,Boolean> map = new HashMap<>();
map.put("isRun",isRun);
map.put("isRun2",isRun2);
return map;
}
} }

View File

@@ -194,7 +194,7 @@ public class PlcRead implements Runnable {
void closeServer() { void closeServer() {
if (readWriteNet != null) { if (readWriteNet != null) {
siemensS7Net.ConnectClose(); readWriteNet.ConnectClose();
} }
setIsConnect(false); setIsConnect(false);
} }

View File

@@ -108,6 +108,8 @@ public class BsOutSsjThread implements Runnable {
if (CollUtil.isNotEmpty(agvQueueList)){ if (CollUtil.isNotEmpty(agvQueueList)){
for (AgvQueue queue : agvQueueList) { for (AgvQueue queue : agvQueueList) {
apiService.requestAgvQueue(queue); apiService.requestAgvQueue(queue);
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(queue);
} }
} }
} }

View File

@@ -34,7 +34,7 @@ server:
# 日志配置 # 日志配置
logging: logging:
level: level:
com.ruoyi: error com.ruoyi: debug
org.springframework: warn org.springframework: warn
# 用户配置 # 用户配置

View File

@@ -0,0 +1,42 @@
import request from '@/utils/request'
// 开启plc读取线程
export function startReadPlc() {
return request({
url: '/device/operation/startAllThread',
method: 'get',
})
}
// 停止plc读取线程
export function stopReadPlc() {
return request({
url: '/device/operation/stopAllThread',
method: 'get'
})
}
// 开启plc调度线程
export function startSchedule() {
return request({
url: '/device/operation/startAllThread2',
method: 'get'
})
}
// 关闭plc调度线程
export function stopSchedule() {
return request({
url: '/device/operation/stopAllThread2',
method: 'get'
})
}
// 关闭plc调度线程
export function getScheduleStatus() {
return request({
url: '/device/operation/getScheduleStatus',
method: 'get'
})
}

View File

@@ -1627,5 +1627,25 @@ export default {
a3:'Inbound Conveyor', // 入库输送机 a3:'Inbound Conveyor', // 入库输送机
a4:'Other Conveyor' // 其它输送机 a4:'Other Conveyor' // 其它输送机
} }
},
top:{
read:'read',
startRead:'startRead',
stopRead:'stopRead',
task:'task',
stopTask:'stopTask',
startTask:'startTask',
layOut:'layOut',
personalCenter:'personalCenter',
loginOut:'loginOut',
startReadSuccess:'startReadSuccess',
stopReadSuccess:'stopReadSuccess',
startTaskSuccess:'startTaskSuccess',
stopTaskSuccess:'stopTaskSuccess',
error:'error',
logoutTip:'logoutTip?',
logoutTitle:'logoutTitle',
confirm:'confirm',
cancel:'cancel',
} }
} }

View File

@@ -1628,5 +1628,25 @@ export default {
a3:'Beraktározási szállítószalag', // 入库输送机 a3:'Beraktározási szállítószalag', // 入库输送机
a4:'Egyéb szállítószalag' // 其它输送机 a4:'Egyéb szállítószalag' // 其它输送机
} }
},
top:{
read:'PLC读取',
startRead:'读取PLC',
stopRead:'停止读取',
task:'调度任务',
stopTask:'停止调度',
startTask:'开始调度',
layOut:'布局大小',
personalCenter:'个人中心',
loginOut:'退出登录',
startReadSuccess:'开始读取PLC成功',
stopReadSuccess:'停止读取PLC成功',
startTaskSuccess:'开始调度成功',
stopTaskSuccess:'停止调度成功',
error:'操作错误',
logoutTip:'确定退出登录吗?',
logoutTitle:'提示',
confirm:'确定',
cancel:'取消',
} }
} }

View File

@@ -1628,5 +1628,25 @@ export default {
a3:'入库输送机', a3:'入库输送机',
a4:'其它输送机' a4:'其它输送机'
} }
},
top:{
read:'PLC读取',
startRead:'读取PLC',
stopRead:'停止读取',
task:'调度任务',
stopTask:'停止调度',
startTask:'开始调度',
layOut:'布局大小',
personalCenter:'个人中心',
loginOut:'退出登录',
startReadSuccess:'开始读取PLC成功',
stopReadSuccess:'停止读取PLC成功',
startTaskSuccess:'开始调度成功',
stopTaskSuccess:'停止调度成功',
error:'操作错误',
logoutTip:'确定退出登录吗?',
logoutTitle:'提示',
confirm:'确定',
cancel:'取消',
} }
} }

View File

@@ -7,19 +7,25 @@
<div class="right-menu"> <div class="right-menu">
<template v-if="device!=='mobile'"> <template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" /> <el-tooltip :content="$t('top.read')" effect="dark" placement="bottom">
<el-button class="right-menu-item hover-effect" :type="plcReadStatus ? 'success' : 'info'" size="mini" @click="togglePlcRead">
<!-- <el-tooltip content="源码地址" effect="dark" placement="bottom"> {{ plcReadStatus ? $t('top.stopRead') : $t('top.startRead') }}
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" /> </el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="文档地址" effect="dark" placement="bottom"> <el-tooltip :content="$t('top.task')" effect="dark" placement="bottom">
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" /> <el-button class="right-menu-item hover-effect" :type="plcScheduleStatus ? 'success' : 'info'" size="mini" @click="togglePlcSchedule">
</el-tooltip> --> {{ plcScheduleStatus ? $t('top.stopTask') : $t('top.startTask') }}
</el-button>
</el-tooltip>
<search id="header-search" class="right-menu-item" />
<screenfull id="screenfull" class="right-menu-item hover-effect" /> <screenfull id="screenfull" class="right-menu-item hover-effect" />
<el-tooltip content="布局大小" effect="dark" placement="bottom"> <el-tooltip :content="$t('top.layOut')" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" /> <size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip> </el-tooltip>
@@ -32,10 +38,10 @@
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<router-link to="/user/profile"> <router-link to="/user/profile">
<el-dropdown-item>个人中心</el-dropdown-item> <el-dropdown-item>{{ $t('top.personalCenter') }}</el-dropdown-item>
</router-link> </router-link>
<el-dropdown-item divided @click.native="logout"> <el-dropdown-item divided @click.native="logout">
<span>退出登录</span> <span>{{ $t('top.loginOut') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@@ -55,6 +61,7 @@ import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull' import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect' import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch' import Search from '@/components/HeaderSearch'
import { startReadPlc, stopReadPlc, startSchedule, stopSchedule ,getScheduleStatus} from '@/api/scheduleTask/task'
// import RuoYiGit from '@/components/RuoYi/Git' // import RuoYiGit from '@/components/RuoYi/Git'
// import RuoYiDoc from '@/components/RuoYi/Doc' // import RuoYiDoc from '@/components/RuoYi/Doc'
@@ -70,6 +77,12 @@ export default {
// RuoYiGit, // RuoYiGit,
// RuoYiDoc // RuoYiDoc
}, },
data() {
return {
plcReadStatus: false,
plcScheduleStatus: false
}
},
computed: { computed: {
...mapGetters([ ...mapGetters([
'sidebar', 'sidebar',
@@ -88,6 +101,10 @@ export default {
} }
} }
}, },
created() {
//获取调度状态
this.setScheduleStatus()
},
methods: { methods: {
toggleSideBar() { toggleSideBar() {
this.$store.dispatch('app/toggleSideBar') this.$store.dispatch('app/toggleSideBar')
@@ -95,10 +112,70 @@ export default {
setLayout(event) { setLayout(event) {
this.$emit('setLayout') this.$emit('setLayout')
}, },
setScheduleStatus() {
getScheduleStatus().then(
res => {
this.plcReadStatus = res.data.isRun
this.plcScheduleStatus = res.data.isRun2
}
)
},
async togglePlcRead() {
try {
console.log(this.plcReadStatus)
if (!this.plcReadStatus) {
await startReadPlc().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.startReadSuccess'))
}
}
)
} else {
await stopReadPlc().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.stopReadSuccess'))
}
}
)
}
} catch (error) {
this.$message.error(this.$t('top.error') + error.message)
}
},
async togglePlcSchedule() {
try {
console.log(this.plcScheduleStatus)
if (!this.plcScheduleStatus) {
await startSchedule().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.startTaskSuccess'))
}
}
)
} else {
await stopSchedule().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.stopTaskSuccess'))
}
}
)
}
} catch (error) {
this.$message.error(this.$t('top.error') + error.message)
}
},
logout() { logout() {
this.$confirm('确定注销并退出系统吗?', '提示', { this.$confirm(this.$t('top.logoutTip'), this.$t('top.logoutTitle'), {
confirmButtonText: '确定', confirmButtonText: this.$t('top.confirm') ,
cancelButtonText: '取消', cancelButtonText: this.$t('top.cancel') ,
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {