|
@ -35,7 +35,10 @@ import javax.servlet.http.HttpServletRequest; |
|
|
import java.io.*; |
|
|
import java.io.*; |
|
|
import java.net.InetAddress; |
|
|
import java.net.InetAddress; |
|
|
import java.net.NetworkInterface; |
|
|
import java.net.NetworkInterface; |
|
|
|
|
|
import java.net.SocketException; |
|
|
|
|
|
import java.net.UnknownHostException; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Enumeration; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Pattern; |
|
|
import java.util.regex.Pattern; |
|
@ -260,6 +263,95 @@ public class RFIDController { |
|
|
return ApiResponse.success(macAddr); |
|
|
return ApiResponse.success(macAddr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取设备mac地址Linux") |
|
|
|
|
|
@AnonymousGetMapping("/getDeviceMacLinux") |
|
|
|
|
|
public ApiResponse<Object> getDeviceMacLinux(HttpServletRequest request) { |
|
|
|
|
|
String ipAddress = null; |
|
|
|
|
|
try { |
|
|
|
|
|
ipAddress = request.getHeader("x-forwarded-for"); |
|
|
|
|
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { |
|
|
|
|
|
ipAddress = request.getHeader("Proxy-Client-IP"); |
|
|
|
|
|
} |
|
|
|
|
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { |
|
|
|
|
|
ipAddress = request.getHeader("WL-Proxy-Client-IP"); |
|
|
|
|
|
} |
|
|
|
|
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { |
|
|
|
|
|
ipAddress = request.getRemoteAddr(); |
|
|
|
|
|
if (ipAddress.equals("127.0.0.1")) { |
|
|
|
|
|
// 根据网卡取本机配置的IP |
|
|
|
|
|
InetAddress inet = null; |
|
|
|
|
|
try { |
|
|
|
|
|
inet = InetAddress.getLocalHost(); |
|
|
|
|
|
} catch (UnknownHostException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
ipAddress = inet.getHostAddress(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 |
|
|
|
|
|
if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length() |
|
|
|
|
|
// = 15 |
|
|
|
|
|
if (ipAddress.indexOf(",") > 0) { |
|
|
|
|
|
ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
ipAddress=""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String mac = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
Process process = Runtime.getRuntime().exec("arp "+ipAddress); |
|
|
|
|
|
InputStreamReader ir = new InputStreamReader(process.getInputStream()); |
|
|
|
|
|
LineNumberReader input = new LineNumberReader(ir); |
|
|
|
|
|
String line; |
|
|
|
|
|
StringBuffer s = new StringBuffer(); |
|
|
|
|
|
while ((line = input.readLine()) != null) { |
|
|
|
|
|
s.append(line); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
mac = s.toString(); |
|
|
|
|
|
if (!StringUtils.isEmpty(mac)) { |
|
|
|
|
|
mac = mac.substring(mac.indexOf(":") - 2, mac.lastIndexOf(":") + 3); |
|
|
|
|
|
} else { |
|
|
|
|
|
String str = ""; |
|
|
|
|
|
String XFor = request.getHeader("X-Real-IP"); |
|
|
|
|
|
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) { |
|
|
|
|
|
XFor = request.getHeader("Proxy-Client-IP"); |
|
|
|
|
|
} |
|
|
|
|
|
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) { |
|
|
|
|
|
XFor = request.getHeader("WL-Proxy-Client-IP"); |
|
|
|
|
|
} |
|
|
|
|
|
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) { |
|
|
|
|
|
XFor = request.getHeader("HTTP_CLIENT_IP"); |
|
|
|
|
|
} |
|
|
|
|
|
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) { |
|
|
|
|
|
XFor = request.getHeader("HTTP_X_FORWARDED_FOR"); |
|
|
|
|
|
} |
|
|
|
|
|
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) { |
|
|
|
|
|
XFor = request.getRemoteAddr(); |
|
|
|
|
|
} |
|
|
|
|
|
Process process1 = Runtime.getRuntime().exec("nbtstat -a " + XFor); |
|
|
|
|
|
InputStreamReader ir1 = new InputStreamReader(process1.getInputStream(),"gbk"); |
|
|
|
|
|
LineNumberReader input1 = new LineNumberReader(ir1); |
|
|
|
|
|
for(int i = 0;i<100;i++){ |
|
|
|
|
|
str = input1.readLine(); |
|
|
|
|
|
if(null != str){ |
|
|
|
|
|
if(str.indexOf("MAC 地址")>1){ |
|
|
|
|
|
mac = str.substring(str.indexOf("MAC 地址")+9); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
return ApiResponse.success(mac); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ApiOperation("借出确认列表") |
|
|
@ApiOperation("借出确认列表") |
|
|
@AnonymousGetMapping("/initWaitBorrowList") |
|
|
@AnonymousGetMapping("/initWaitBorrowList") |
|
|
public ApiResponse<Object> initWaitBorrowList( |
|
|
public ApiResponse<Object> initWaitBorrowList( |
|
|