From f5af64aebfcf92d86da144315b0bb4e2a4dca98f Mon Sep 17 00:00:00 2001
From: 懒羊羊 <15939171744@163.com>
Date: 星期四, 18 一月 2024 13:25:30 +0800
Subject: [PATCH] 作业指导工位配置

---
 jcdm-main/src/main/java/com/jcdm/main/util/IpInfoUtils.java                                  |   63 +++++++++++++++++++++++++++++++
 jcdm-ui/src/api/main/sc/stationConf.js                                                       |    8 ++++
 jcdm-ui/src/views/main/cfkb/Instructions/index.vue                                           |   16 +++++++
 jcdm-main/src/main/java/com/jcdm/main/sc/stationConf/controller/ScStationConfController.java |   13 ++++++
 4 files changed, 99 insertions(+), 1 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/sc/stationConf/controller/ScStationConfController.java b/jcdm-main/src/main/java/com/jcdm/main/sc/stationConf/controller/ScStationConfController.java
index fa44622..4cb928b 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/sc/stationConf/controller/ScStationConfController.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/sc/stationConf/controller/ScStationConfController.java
@@ -1,7 +1,11 @@
 package com.jcdm.main.sc.stationConf.controller;
 
 import java.util.List;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import com.jcdm.main.util.IpInfoUtils;
+import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -101,4 +105,13 @@
     {
         return toAjax(scStationConfService.deleteScStationConfByIds(ids));
     }
+
+    /**
+     * 鏌ヨip
+     */
+    @GetMapping("/getIp")
+    public AjaxResult getIp(HttpServletRequest request)
+    {
+        return AjaxResult.success(IpInfoUtils.getIpAddr(request));
+    }
 }
diff --git a/jcdm-main/src/main/java/com/jcdm/main/util/IpInfoUtils.java b/jcdm-main/src/main/java/com/jcdm/main/util/IpInfoUtils.java
new file mode 100644
index 0000000..93c7161
--- /dev/null
+++ b/jcdm-main/src/main/java/com/jcdm/main/util/IpInfoUtils.java
@@ -0,0 +1,63 @@
+package com.jcdm.main.util;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * ip宸ュ叿绫�
+ *
+ * @author fengshuonan
+ * @Date 2018/9/27 涓婂崍10:47
+ */
+public class IpInfoUtils {
+
+    /**
+     * 鑾峰彇瀹㈡埛绔疘P鍦板潃
+     */
+    public static String getIpAddr(HttpServletRequest request) {
+        String ip = request.getHeader("x-forwarded-for");
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+            if (ip.equals("127.0.0.1")) {
+                //鏍规嵁缃戝崱鍙栨湰鏈洪厤缃殑IP
+                InetAddress inet = null;
+                try {
+                    inet = InetAddress.getLocalHost();
+                } catch (UnknownHostException e) {
+                    e.printStackTrace();
+                }
+                ip = inet.getHostAddress();
+            }
+        }
+        // 瀵逛簬閫氳繃澶氫釜浠g悊鐨勬儏鍐碉紝绗竴涓狪P涓哄鎴风鐪熷疄IP,澶氫釜IP鎸夌収','鍒嗗壊
+        if (ip != null && ip.length() > 15) {
+            if (ip.indexOf(",") > 0) {
+                ip = ip.substring(0, ip.indexOf(","));
+            }
+        }
+
+        if ("0:0:0:0:0:0:0:1".equals(ip)) {
+            ip = "127.0.0.1";
+        }
+
+        return ip;
+    }
+
+    /**
+     * 鑾峰彇瀹㈡埛绔富鏈哄悕绉�
+     */
+    public static String getHostName() {
+        try {
+            return InetAddress.getLocalHost().getHostName();
+        } catch (UnknownHostException e) {
+        }
+        return "鏈煡";
+    }
+}
diff --git a/jcdm-ui/src/api/main/sc/stationConf.js b/jcdm-ui/src/api/main/sc/stationConf.js
index baebb1e..9c51122 100644
--- a/jcdm-ui/src/api/main/sc/stationConf.js
+++ b/jcdm-ui/src/api/main/sc/stationConf.js
@@ -9,6 +9,14 @@
   })
 }
 
+// 鏌ヨIp
+export function getIp() {
+  return request({
+    url: '/sc/stationConf/getIp',
+    method: 'get',
+  })
+}
+
 // 鏌ヨ宸ヤ綅缁堢閰嶇疆璇︾粏
 export function getStationConf(id) {
   return request({
diff --git a/jcdm-ui/src/views/main/cfkb/Instructions/index.vue b/jcdm-ui/src/views/main/cfkb/Instructions/index.vue
index 4d6c15b..7097c32 100644
--- a/jcdm-ui/src/views/main/cfkb/Instructions/index.vue
+++ b/jcdm-ui/src/views/main/cfkb/Instructions/index.vue
@@ -14,7 +14,7 @@
       </el-col>
       <el-col :span="15">
         <el-card shadow="always">
-          <span class="centerText">瑁呭壇杞�,鎷ㄥ弶</span>
+          <span class="centerText">{{locationName}}</span>
         </el-card>
       </el-col>
     </el-row>
@@ -74,11 +74,13 @@
 
 <script>
 import {listFormulaChild} from "@/api/main/bs/formulaChild/formulaChild";
+import {listStationConf,getIp} from "@/api/main/sc/stationConf";
 
 export default {
   name: "index",
   data() {
     return {
+      locationName: "鏈厤缃伐浣�",
       queryParams: {
         pageNum: 1,
         pageSize: 10,
@@ -143,6 +145,7 @@
     this.tableData = []
   },
   mounted() {
+    this.getStationConf()
     this.changeProducts(this.productCode)
     this.getNowTime()
     // this.autoShow()
@@ -151,6 +154,17 @@
   //   currentTime:
   // },
   methods: {
+    /** 鏌ヨ宸ヤ綅缁堢閰嶇疆鍒楄〃 */
+    getStationConf() {
+      getIp().then(response => {
+        let queryParams = {
+          ipAddress: response.msg,
+        }
+        listStationConf(queryParams).then(response => {
+          this.locationName = response.rows[0].processesName
+        });
+      });
+    },
     //鑾峰彇褰撳墠鏃堕棿
     getNowTime () {
       let speed = 1000

--
Gitblit v1.9.3