src/main/java/com/zy/client/constant/WcsSystemPropety.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/client/controller/ConsoleController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/client/domain/param/SystemSwitchParam.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/webapp/views/console.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/client/constant/WcsSystemPropety.java
New file @@ -0,0 +1,15 @@ package com.zy.client.constant; import java.util.concurrent.atomic.AtomicBoolean; /** * Created by vincent on 2020-06-03 */ public class WcsSystemPropety { public static final String WCS_PASSWORD = "root"; // 系统运行状态 public static final AtomicBoolean WCS_RUNNING_STATUS = new AtomicBoolean(false); } src/main/java/com/zy/client/controller/ConsoleController.java
@@ -1,10 +1,13 @@ package com.zy.client.controller; import com.core.annotations.ManagerAuth; import com.core.common.Cools; import com.core.common.R; import com.zy.client.constant.WcsSystemPropety; import com.zy.client.domain.enums.SiteStatusType; import com.zy.client.domain.param.SystemSwitchParam; import com.zy.client.domain.vo.CrnLatestDataVo; import com.zy.client.domain.vo.SiteLatestDataVo; import com.zy.client.domain.enums.SiteStatusType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -21,6 +24,59 @@ @RequestMapping("/console") public class ConsoleController { @PostMapping("/system/running/status") @ManagerAuth(memo = "系统运行状态") public R systemRunningStatus(){ return R.ok().add(Cools.add("status", WcsSystemPropety.WCS_RUNNING_STATUS.get())); } @PostMapping("/system/switch") @ManagerAuth(memo = "系统运行开关操作") public R systemSwitch(SystemSwitchParam param) throws InterruptedException { if (Cools.isEmpty(param.getOperatorType())){ return R.error(); } if (param.getOperatorType() == 0) { if (Cools.isEmpty(param.getPassword())){ return R.error("请输入口令"); } if (!param.getPassword().equals(WcsSystemPropety.WCS_PASSWORD)){ return R.error("口令错误"); } } Thread.sleep(2000L); WcsSystemPropety.WCS_RUNNING_STATUS.set(param.getOperatorType()==1?Boolean.TRUE:Boolean.FALSE); return R.ok().add(Cools.add("status", WcsSystemPropety.WCS_RUNNING_STATUS.get())); } @PostMapping("/site/detail") @ManagerAuth(memo = "输送设备数据详情") public R siteDetail(){ return R.ok(); } @PostMapping("/crn/detail") @ManagerAuth(memo = "堆垛机设备数据详情") public R crnDetail(){ return R.ok(); } @PostMapping("/site/update") @ManagerAuth(memo = "输送设备数据修改") public R updateSite(){ return R.ok(); } @PostMapping("/crn/update") @ManagerAuth(memo = "堆垛机数据修改") public R updateCrn(){ return R.ok(); } /****************************************************************/ /************************** 实时数据 ******************************/ /****************************************************************/ @PostMapping("/latest/data/site") @ManagerAuth(memo = "站点实时数据") public R siteLatestData(){ src/main/java/com/zy/client/domain/param/SystemSwitchParam.java
New file @@ -0,0 +1,30 @@ package com.zy.client.domain.param; /** * 系统运行状态操作入参 * Created by vincent on 2020-06-03 */ public class SystemSwitchParam { // 操作类型 1: 打开; 0: 关闭 private Integer operatorType; // 密码口令 private String password; public Integer getOperatorType() { return operatorType; } public void setOperatorType(Integer operatorType) { this.operatorType = operatorType; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } src/main/webapp/views/console.html
@@ -625,9 +625,11 @@ // 初始化 getSitesInfo(); getCrnInfo(); getSystemRunningStatus(); // 实时访问 setInterval(function () { getCrnInfo(); getSystemRunningStatus(); }, 500); setInterval(function () { getSitesInfo(); @@ -638,46 +640,75 @@ if (systemRunning){ layer.prompt({title: '请输入口令,并停止 WCS 系统', formType: 1, shadeClose: true}, function(pass, idx){ layer.close(idx); if ("123"!==pass){ alert("口令错误"); return; } var index = null; index = layer.load(1, { shade: [0.1,'#fff'] }); setTimeout(function () { if (systemRunning){ $('#system-icon').attr("class", "system-icon-close"); $('#system-run-desc').html("系统已停止!"); systemRunning = false; } else { doSwitch(0, pass); }); } else { doSwitch(1) } } // 请求服务器控制wcs系统运行状态 function doSwitch(operatorType, password) { // 加载tips var index = layer.load(1, { shade: [0.1,'#fff'] }); $.ajax({ url: baseUrl+ "/console/system/switch", headers: {'token': localStorage.getItem('token')}, // async: false, data: { operatorType: operatorType, password: password }, method: 'POST', success: function (res) { if (res.code === 200){ layer.close(index); if (res.data.status) { $('#system-icon').attr("class", "system-icon-open"); $('#system-run-desc').html("系统运行中..."); systemRunning = true; } else { $('#system-icon').attr("class", "system-icon-close"); $('#system-run-desc').html("系统已停止!"); systemRunning = false; } layer.close(index); }, 2000); }); } else { var index = null; index = layer.load(1, { shade: [0.1,'#fff'] }); setTimeout(function () { if (systemRunning){ $('#system-icon').attr("class", "system-icon-close"); $('#system-run-desc').html("系统已停止!"); systemRunning = false; } else { $('#system-icon').attr("class", "system-icon-open"); $('#system-run-desc').html("系统运行中..."); systemRunning = true; } else if (res.code === 403){ top.location.href = baseUrl+"/login"; } else { alert(res.msg); } layer.close(index); }, 2000); } } }); } // 获取wcs系统运行状态 function getSystemRunningStatus() { $.ajax({ url: baseUrl+ "/console/system/running/status", headers: {'token': localStorage.getItem('token')}, method: 'POST', success: function (res) { if (res.code === 200){ if (res.data.status) { $('#system-icon').attr("class", "system-icon-open"); $('#system-run-desc').html("系统运行中..."); systemRunning = true; } else { $('#system-icon').attr("class", "system-icon-close"); $('#system-run-desc').html("系统已停止!"); systemRunning = false; } } else if (res.code === 403){ top.location.href = baseUrl+"/login"; } else { alert(res.msg); } } }); } // 输送设备实时数据获取