From 45e4c1543eaacc87ccf67a7ae91d2a8bb5b82ddc Mon Sep 17 00:00:00 2001 From: vincent <1341870251@qq.com> Date: 星期三, 03 六月 2020 13:27:15 +0800 Subject: [PATCH] # --- src/main/java/com/zy/client/constant/WcsSystemPropety.java | 15 +++ src/main/webapp/views/console.html | 101 ++++++++++++++++-------- src/main/java/com/zy/client/domain/param/SystemSwitchParam.java | 30 +++++++ src/main/java/com/zy/client/controller/ConsoleController.java | 58 ++++++++++++++ 4 files changed, 168 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/zy/client/constant/WcsSystemPropety.java b/src/main/java/com/zy/client/constant/WcsSystemPropety.java new file mode 100644 index 0000000..3a762f5 --- /dev/null +++ b/src/main/java/com/zy/client/constant/WcsSystemPropety.java @@ -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); + +} diff --git a/src/main/java/com/zy/client/controller/ConsoleController.java b/src/main/java/com/zy/client/controller/ConsoleController.java index 720d7c6..7cce864 100644 --- a/src/main/java/com/zy/client/controller/ConsoleController.java +++ b/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("鍙d护閿欒"); + } + } + 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(){ diff --git a/src/main/java/com/zy/client/domain/param/SystemSwitchParam.java b/src/main/java/com/zy/client/domain/param/SystemSwitchParam.java new file mode 100644 index 0000000..8d20e6e --- /dev/null +++ b/src/main/java/com/zy/client/domain/param/SystemSwitchParam.java @@ -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; + + // 瀵嗙爜鍙d护 + 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; + } +} diff --git a/src/main/webapp/views/console.html b/src/main/webapp/views/console.html index 56663d2..5666f17 100644 --- a/src/main/webapp/views/console.html +++ b/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("鍙d护閿欒"); - 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) + } + + } + + // 璇锋眰鏈嶅姟鍣ㄦ帶鍒秝cs绯荤粺杩愯鐘舵�� + 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); + } + } + }); } // 杈撻�佽澶囧疄鏃舵暟鎹幏鍙� -- Gitblit v1.9.1