From 4e6483bb021db0a13a27fa12863a983369a083ea Mon Sep 17 00:00:00 2001
From: DELL <DELL@qq.com>
Date: 星期四, 27 十一月 2025 17:00:09 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/OpenController.java |   48 ++++++++++++++++++++++++
 src/main/webapp/views/index.html                         |   68 ++++++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 0aa3632..0522ff4 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -14,8 +14,12 @@
 import com.zy.common.annotations.OpenApiLog;
 import com.zy.common.service.CommonService;
 import com.zy.core.enums.WrkIoType;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
+
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
@@ -28,6 +32,8 @@
 @RequestMapping("/openapi")
 public class OpenController {
 
+    @Value("${mainProcessPlugin}")
+    private String mainProcessPlugin;
     @Autowired
     private CommonService commonService;
     @Autowired
@@ -38,6 +44,8 @@
     private LocMastService locMastService;
     @Autowired
     private WrkMastService wrkMastService;
+    @Autowired
+    private ConfigService configService;
 
     //绉诲簱浠诲姟
     @PostMapping("/createLocMoveTask")
@@ -327,4 +335,44 @@
         return R.ok();
     }
 
+    @GetMapping("/getFakeSystemRunStatus")
+    public R getFakeSystemRunStatus() {
+        HashMap<String, Object> map = new HashMap<>();
+        if(mainProcessPlugin.equals("FakeProcess")) {
+            map.put("running", false);
+            map.put("isFake", true);
+            Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+            if(config != null) {
+                if(config.getValue().equals("Y")) {
+                    map.put("running", true);
+                }
+            }
+        } else {
+            map.put("isFake", false);
+        }
+        return R.ok().add(map);
+    }
+
+    @PostMapping("/startFakeSystem")
+    @OpenApiLog(memo = "鍚姩浠跨湡妯℃嫙")
+    public R startFakeSystem() {
+        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+        if(config != null) {
+            config.setValue("Y");
+            configService.updateById(config);
+        }
+        return R.ok();
+    }
+
+    @PostMapping("/stopFakeSystem")
+    @OpenApiLog(memo = "鍋滄浠跨湡妯℃嫙")
+    public R stopFakeSystem() {
+        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+        if(config != null) {
+            config.setValue("N");
+            configService.updateById(config);
+        }
+        return R.ok();
+    }
+
 }
diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html
index e7e5e93..fee90ed 100644
--- a/src/main/webapp/views/index.html
+++ b/src/main/webapp/views/index.html
@@ -43,6 +43,9 @@
 <!--      <li class="layui-nav-item" lay-unselect>-->
 <!--        <a ew-event="note" title="渚跨"><i class="layui-icon layui-icon-note"></i></a>-->
 <!--      </li>-->
+      <li class="layui-nav-item" lay-unselect id="fakeShow" style="display: none;user-select: none;">
+        <div style="color: red;" id="fakeShowText">浠跨湡妯℃嫙杩愯涓�</div>
+      </li>
       <li class="layui-nav-item" lay-unselect id="licenseShow" style="display: none;user-select: none;">
         <div style="color: red;">璁稿彲璇佹湁鏁堟湡锛�<span id="licenseDays">29</span>澶�</div>
       </li>
@@ -120,6 +123,71 @@
       }
     }
 
+    let fakeRunning = false
+    setInterval(function () {
+      $.ajax({
+        url: baseUrl + "/openapi/getFakeSystemRunStatus",
+        headers: {'token': localStorage.getItem('token')},
+        method: 'GET',
+        success: function (res) {
+          if (res.code === 200) {
+            if(res.data.isFake) {
+              $("#fakeShow").show()
+              let running = res.data.running
+              if (running) {
+                $("#fakeShowText").text("浠跨湡妯℃嫙杩愯涓�")
+              } else {
+                $("#fakeShowText").text("浠跨湡妯℃嫙鏈繍琛�")
+              }
+              fakeRunning = running
+            }else {
+              $("#fakeShow").hide()
+            }
+          }else {
+            top.location.href = baseUrl + "/login";
+          }
+        }
+      });
+    }, 1000);
+
+    $("#fakeShow").on("click", function () {
+      if (fakeRunning) {
+        layer.confirm('纭畾瑕佸仠姝豢鐪熸ā鎷熷悧锛�', function (index) {
+          layer.close(index);
+          $.ajax({
+            url: baseUrl + "/openapi/stopFakeSystem",
+            headers: {'token': localStorage.getItem('token')},
+            method: 'POST',
+            success: function (res) {
+              if (res.code === 200) {
+                layer.msg("浠跨湡妯℃嫙宸插仠姝�", {icon: 1});
+                $("#fakeShowText").text("浠跨湡妯℃嫙鏈繍琛�")
+              } else {
+                layer.msg(res.msg, {icon: 2});
+              }
+            }
+          });
+        });
+      } else {
+        layer.confirm('纭畾瑕佸惎鍔ㄤ豢鐪熸ā鎷熷悧锛�', function (index) {
+          layer.close(index);
+          $.ajax({
+            url: baseUrl + "/openapi/startFakeSystem",
+            headers: {'token': localStorage.getItem('token')},
+            method: 'POST',
+            success: function (res) {
+              if (res.code === 200) {
+                layer.msg("浠跨湡妯℃嫙宸插惎鍔�", {icon: 1});
+                $("#fakeShowText").text("浠跨湡妯℃嫙杩愯涓�")
+              } else {
+                layer.msg(res.msg, {icon: 2});
+              }
+            }
+          });
+        });
+      }
+    });
+
     $.ajax({
       url: baseUrl + "/menu/auth",
       headers: {'token': localStorage.getItem('token')},

--
Gitblit v1.9.1