diff --git a/src/main/java/com/watu/wifi/controller/WifiController.java b/src/main/java/com/watu/wifi/controller/WifiController.java index 959dee8..75256a8 100644 --- a/src/main/java/com/watu/wifi/controller/WifiController.java +++ b/src/main/java/com/watu/wifi/controller/WifiController.java @@ -1,5 +1,6 @@ package com.watu.wifi.controller; +import cn.hutool.http.HttpResponse; import com.watu.wifi.entity.ResObject; import com.watu.wifi.service.impl.wifiExcelBluetoothServiceImpl; import com.watu.wifi.service.impl.wifiExcelServiceImpl; @@ -12,6 +13,9 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; @@ -66,13 +70,49 @@ public class WifiController { // } @PostMapping("/Wificd/mac_agent/index/mac.do") - public ResObject jsonmac(@RequestParam("apmac") String date,String gwid){ + public ResObject jsonmac(@RequestParam("mac") String date,String gwid){ log.info("调用接口入参:"+date); executor.submit(()->{ wifiExcelBluetoothService.jsonParsingMac(date,gwid); }); return new ResObject(); } + +// @PostMapping("/Wificd/mac_agent/index/ver.do") +// public void jsonver(@RequestParam("Info") String date, HttpServletResponse response){ +// log.info("调用接口入参:"+date); +// response.setContentType("application/json"); +// response.setCharacterEncoding("UTF-8"); +// String jsonParsingVer = wifiExcelBluetoothService.jsonParsingVer(date); +// +// try (PrintWriter out = response.getWriter()) { +// out.print(jsonParsingVer); +// out.flush(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } + + @PostMapping("/Wificd/mac_agent/index/ver.do") + public String jsonver(@RequestParam("Info") String date){ + log.info("调用接口入参:"+date); + String jsonParsingVer = wifiExcelBluetoothService.jsonParsingVer(date); + log.info("调用接口出参:"+jsonParsingVer); + return jsonParsingVer; + } + + @PostMapping("/Wificd/mac_agent/index/vssid.do") + public String jsonvssid(@RequestParam("vssid") String date){ + log.info("调用接口入参:"+date); + String jsonParsingVer = wifiExcelBluetoothService.jsonParsingVer(date); + log.info("调用接口出参:"+jsonParsingVer); + return ""; + } + + + + + @PostMapping("/mac.do") public ResObject jsonmac2(@RequestBody String date,String gwid){ log.info("调用接口入参:"+date +"gwid:"+gwid); diff --git a/src/main/java/com/watu/wifi/service/impl/wifiExcelBluetoothServiceImpl.java b/src/main/java/com/watu/wifi/service/impl/wifiExcelBluetoothServiceImpl.java index 52bcecc..2bef7f2 100644 --- a/src/main/java/com/watu/wifi/service/impl/wifiExcelBluetoothServiceImpl.java +++ b/src/main/java/com/watu/wifi/service/impl/wifiExcelBluetoothServiceImpl.java @@ -93,7 +93,8 @@ public class wifiExcelBluetoothServiceImpl implements wifiExcelBluetoothService wifiName= getSafeString(dataObject, "router"); } //手机MAC - result.append(phoneMAC).append(","); + String mac = convertToUpper(phoneMAC); + result.append(mac).append(","); //信号强度 result.append(getSafeString(dataObject, "rssi")).append(","); //手机与采集设备之间的预估距离 @@ -122,7 +123,8 @@ public class wifiExcelBluetoothServiceImpl implements wifiExcelBluetoothService String collectDeviceIp = ExcelReader.getmap("collectDeviceIp", id); result.append(collectDeviceIp).append(","); //路由器mac - result.append(wifiMAC).append("\n"); + String wifimac = convertToUpper(wifiMAC); + result.append(wifimac).append("\n"); results.append(result); @@ -295,8 +297,9 @@ public class wifiExcelBluetoothServiceImpl implements wifiExcelBluetoothService result.append(timestamp).append(","); //手机MAC - - result.append(getSafeString(dataObject, "s")).append(","); + String safeString = getSafeString(dataObject, "s"); + String convertToUpper = convertToUpper(safeString); + result.append(convertToUpper).append(","); //信号强度 result.append(getSafeString(dataObject, "p")).append(","); //手机与采集设备之间的预估距离 @@ -317,7 +320,9 @@ public class wifiExcelBluetoothServiceImpl implements wifiExcelBluetoothService String collectDeviceIp = ExcelReader.getmap("collectDeviceIp", gwid); result.append(collectDeviceIp).append(","); //路由器mac - result.append(getSafeString(dataObject, "a")).append("\n"); + String a = getSafeString(dataObject, "a"); + String a1 = convertToUpper(a); + result.append(a1).append("\n"); results.append(result); @@ -337,6 +342,31 @@ public class wifiExcelBluetoothServiceImpl implements wifiExcelBluetoothService return null; } + @Override + public String jsonParsingVer(String json) { + + + + try { + //解析json + JSONObject jsonObject = new JSONObject(json); + + } catch (Exception e) { + e.printStackTrace(); + System.out.println("捕获异常= "+e+"json:"+json); + } + + return "{\"ap\":{\"pwd\":\"\",\"ssid\":\"\"},\"ftpserver\":{\"ip\":\"\",\"path\":\"\",\"port\":\"\",\"pwd\":\"\",\"user\":\"\"},\"httpserver\":{\"url\":\"\"},\"ntpserver\":{\"ip\":\"\"},\"reboot\":{\"value\":\"\"},\"runmode\":{\"value\":\"\"},\"transfer\":{\"value\":\"\"},\"upgrade\":{\"filename\":\"\",\"ftpport\":\"\",\"ftppwd\":\"\",\"ftpserver\":\"\",\"ftpuser\":\"\",\"isupgrade\":\"\",\"md5\":\"\",\"ver\":\"\"}}{\"ap\":{\"pwd\":\"\",\"ssid\":\"\"},\"ftpserver\":{\"ip\":\"\",\"path\":\"\",\"port\":\"\",\"pwd\":\"\",\"user\":\"\"},\"httpserver\":{\"url\":\"\"},\"ntpserver\":{\"ip\":\"\"},\"reboot\":{\"value\":\"\"},\"runmode\":{\"value\":\"\"},\"transfer\":{\"value\":\"\"},\"upgrade\":{\"filename\":\"\",\"ftpport\":\"\",\"ftppwd\":\"\",\"ftpserver\":\"\",\"ftpuser\":\"\",\"isupgrade\":\"\",\"md5\":\"\",\"ver\":\"\"}}"; + } + + public static String convertToUpper(String input) { + // 检查输入是否为空 + if (input == null || input.isEmpty()) { + return "null"; + } + // 将所有小写字母转换为大写字母 + return input.toUpperCase(); + } public static String decodeUrl(String encodedString) throws UnsupportedEncodingException { if(StringUtils.isEmpty(encodedString)){ diff --git a/src/main/java/com/watu/wifi/service/wifiExcelBluetoothService.java b/src/main/java/com/watu/wifi/service/wifiExcelBluetoothService.java index 126703c..14dda39 100644 --- a/src/main/java/com/watu/wifi/service/wifiExcelBluetoothService.java +++ b/src/main/java/com/watu/wifi/service/wifiExcelBluetoothService.java @@ -5,4 +5,5 @@ public interface wifiExcelBluetoothService { String jsonParsing(String json); String jsonParsingApmac(String json,String gwid); String jsonParsingMac(String json,String gwid); + String jsonParsingVer(String json); }