Browse Source

阶段性提交,还有学工,设备数据未获取。

soft5566 3 years ago
parent
commit
3abcdd8b9f

+ 34 - 9
src/main/java/com/ch/jiaoxuelou_houtai/controller/ApiController.java

@@ -3,8 +3,10 @@ package com.ch.jiaoxuelou_houtai.controller;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONObject;
 import com.ch.jiaoxuelou_houtai.core.ResponseResult;
 import com.ch.jiaoxuelou_houtai.core.ResponseResult;
 import com.ch.jiaoxuelou_houtai.entity.Course;
 import com.ch.jiaoxuelou_houtai.entity.Course;
+import com.ch.jiaoxuelou_houtai.entity.EnvTesting;
 import com.ch.jiaoxuelou_houtai.service.CourseService;
 import com.ch.jiaoxuelou_houtai.service.CourseService;
 import com.ch.jiaoxuelou_houtai.util.DateTimeUtil;
 import com.ch.jiaoxuelou_houtai.util.DateTimeUtil;
+import com.ch.jiaoxuelou_houtai.util.DbUtil;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -12,7 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 
 
@@ -25,10 +30,11 @@ public class ApiController {
 
 
     /**
     /**
      * 教室使用情况
      * 教室使用情况
+     *
      * @param jsonObject
      * @param jsonObject
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/theClassrooms", method = RequestMethod.GET)
+    @RequestMapping(value = "/theClassrooms", method = RequestMethod.POST)
     public ResponseResult getNumOfUsingClassRoom(@RequestBody JSONObject jsonObject) {
     public ResponseResult getNumOfUsingClassRoom(@RequestBody JSONObject jsonObject) {
         // 如:博学楼
         // 如:博学楼
         String building = jsonObject.getString("building");
         String building = jsonObject.getString("building");
@@ -62,10 +68,11 @@ public class ApiController {
             section = "9-";
             section = "9-";
         else
         else
             section = "未使用";
             section = "未使用";
+        // 获取教室总数量
+//        int totalOfClassRoom = courseService.getTotalOfClassRoom(building);
+        int totalOfClassRoom = 118;
         // 获取正在使用的教室总数量
         // 获取正在使用的教室总数量
         int numOfUsingClassRoom = courseService.getNumOfUsingClassRoom(building, schoolYear, semester, weeks, week, section);
         int numOfUsingClassRoom = courseService.getNumOfUsingClassRoom(building, schoolYear, semester, weeks, week, section);
-        // 获取教室总数量
-        int totalOfClassRoom = courseService.getTotalOfClassRoom(building);
         // 使用中的教室百分比
         // 使用中的教室百分比
         double totalUsingPercent = (numOfUsingClassRoom / (double) totalOfClassRoom) * 100;
         double totalUsingPercent = (numOfUsingClassRoom / (double) totalOfClassRoom) * 100;
         totalUsingPercent = (double) Math.round(totalUsingPercent * 100) / 100;
         totalUsingPercent = (double) Math.round(totalUsingPercent * 100) / 100;
@@ -85,10 +92,11 @@ public class ApiController {
 
 
     /**
     /**
      * 教室排课表
      * 教室排课表
+     *
      * @param jsonObject
      * @param jsonObject
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/listCourse", method = RequestMethod.GET)
+    @RequestMapping(value = "/listCourse", method = RequestMethod.POST)
     public ResponseResult listCourse(@RequestBody JSONObject jsonObject) {
     public ResponseResult listCourse(@RequestBody JSONObject jsonObject) {
         int pageNum = jsonObject.getInteger("pageNum");
         int pageNum = jsonObject.getInteger("pageNum");
         int pageSize = jsonObject.getInteger("pageSize");
         int pageSize = jsonObject.getInteger("pageSize");
@@ -162,10 +170,11 @@ public class ApiController {
 
 
     /**
     /**
      * 调整开学日期,用于获取当前是第几周
      * 调整开学日期,用于获取当前是第几周
+     *
      * @param jsonObject
      * @param jsonObject
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/updateTermBeginsDate", method = RequestMethod.GET)
+    @RequestMapping(value = "/updateTermBeginsDate", method = RequestMethod.POST)
     public ResponseResult updateTermBeginsDate(@RequestBody JSONObject jsonObject) {
     public ResponseResult updateTermBeginsDate(@RequestBody JSONObject jsonObject) {
         String date = jsonObject.getString("termBeginsDate");
         String date = jsonObject.getString("termBeginsDate");
         int row = courseService.updateTermBeginsDate(date);
         int row = courseService.updateTermBeginsDate(date);
@@ -177,9 +186,10 @@ public class ApiController {
 
 
     /**
     /**
      * 获取学工各年级的获奖人数
      * 获取学工各年级的获奖人数
+     *
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/getNumbOfAwardWinners", method = RequestMethod.GET)
+    @RequestMapping(value = "/getNumbOfAwardWinners", method = RequestMethod.POST)
     public ResponseResult getNumbOfAwardWinners() {
     public ResponseResult getNumbOfAwardWinners() {
         Map<String, Integer> data = new HashMap<>();
         Map<String, Integer> data = new HashMap<>();
         data.put("2020级", 780);
         data.put("2020级", 780);
@@ -190,9 +200,24 @@ public class ApiController {
         return ResponseResult.success(data);
         return ResponseResult.success(data);
     }
     }
 
 
-    @RequestMapping(value = "/teaEnvTesting", method = RequestMethod.GET)
+    /**
+     * 环境检测数据
+     * @return
+     */
+    @RequestMapping(value = "/teaEnvTesting", method = RequestMethod.POST)
     public ResponseResult teachingEnvironmentTesting() {
     public ResponseResult teachingEnvironmentTesting() {
-
-        return ResponseResult.success("pass");
+        HashMap<Object, Object> map = new HashMap<>();
+        DbUtil dbUtil = new DbUtil();
+        List<EnvTesting> envTestings = dbUtil.executeQuery("SELECT id, point_code, point_name, point_location, temperature, humidity," +
+                " negaticeO2Ion, pm25, pm10, db, update_time " +
+                " FROM environment_data_record " +
+                " WHERE point_name = '行政楼' " +
+                " ORDER BY update_time DESC " +
+                " LIMIT 1 ");
+
+        if (envTestings.size() == 0) {
+            return  ResponseResult.failed("获取环境检测数据为空!");
+        }
+        return ResponseResult.success(envTestings);
     }
     }
 }
 }

+ 112 - 4
src/main/java/com/ch/jiaoxuelou_houtai/controller/VideoController.java

@@ -56,7 +56,7 @@ public class VideoController {
      * @param jsonObject
      * @param jsonObject
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/getVideoList", method = RequestMethod.GET)
+    @RequestMapping(value = "/getVideoList", method = RequestMethod.POST)
     public ResponseResult getVideoList(@RequestBody JSONObject jsonObject) {
     public ResponseResult getVideoList(@RequestBody JSONObject jsonObject) {
         // 先登录,获取token
         // 先登录,获取token
         String admin_token = login();
         String admin_token = login();
@@ -91,9 +91,9 @@ public class VideoController {
      *
      *
      * @return
      * @return
      */
      */
-    @RequestMapping(value = "/getAirOverTime", method = RequestMethod.GET)
+    @RequestMapping(value = "/getAirOverTime", method = RequestMethod.POST)
     public ResponseResult getAirOverTime() {
     public ResponseResult getAirOverTime() {
-        // 视频列表接口URL
+        // 接口URL
         String url = "https://chtech.ncjti.edu.cn/air-conditioner-control/airManage/firstqueryOverTime.action";
         String url = "https://chtech.ncjti.edu.cn/air-conditioner-control/airManage/firstqueryOverTime.action";
         // 请求头
         // 请求头
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
@@ -105,7 +105,7 @@ public class VideoController {
         formData.put("rows", "10");
         formData.put("rows", "10");
         // 调用方法
         // 调用方法
         JSONObject airOverTime = videoService.getAirOverTime(url, formData, headers);
         JSONObject airOverTime = videoService.getAirOverTime(url, formData, headers);
-        // 判断视频列表是否为空
+        // 判断是否为空
         if (airOverTime.isEmpty()) {
         if (airOverTime.isEmpty()) {
             return ResponseResult.failed("获取教室列表失败!");
             return ResponseResult.failed("获取教室列表失败!");
         }
         }
@@ -114,6 +114,114 @@ public class VideoController {
     }
     }
 
 
     /**
     /**
+     * 获取空调总数和在线数
+     * @return
+     */
+    private Map<String, String> getAirUsage() {
+        Map<String, String> returnMap = new HashMap<>();
+        // 接口URL
+        String url = "https://chtech.ncjti.edu.cn/air-conditioner-control/airManage/firstqueryOn.action";
+        // 请求头
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Admin-Name", "admin");
+        headers.put("X-Token", "admin_token");
+        // 调用方法
+        JSONObject airRealTime = videoService.getAirRealTime(url, headers);
+        // 判断是否为空
+        if (airRealTime.isEmpty()) {
+            returnMap.put("code", "-1");
+            returnMap.put("msg", "获取空调使用情况为空!");
+            returnMap.put("air_total", "0");
+            returnMap.put("air_on_total", "0");
+        } else {
+            returnMap.put("code", "200");
+            returnMap.put("msg", "获取空调使用情况成功!");
+            returnMap.put("air_total", airRealTime.getString("air_total"));
+            returnMap.put("air_on_using", airRealTime.getString("air_on_total"));
+        }
+
+        return returnMap;
+    }
+
+    /**
+     * 电脑使用情况
+     * @return
+     */
+    private Map<String, String> getComputerUsage() {
+        Map<String, String> returnMap = new HashMap<>();
+        // 判断是否为空
+        if (false) {
+            returnMap.put("code", "-1");
+            returnMap.put("msg", "获取电脑使用情况为空!");
+            returnMap.put("air_total", "0");
+            returnMap.put("air_on_total", "0");
+        } else {
+            returnMap.put("code", "200");
+            returnMap.put("msg", "获取电脑使用情况成功!");
+            returnMap.put("computer_total", "100");
+            returnMap.put("computer_on_using", "200");
+        }
+
+        return returnMap;
+    }
+
+    /**
+     * 摄像头使用情况
+     * @return
+     */
+    private Map<String, String> getProjectorUsage() {
+        Map<String, String> returnMap = new HashMap<>();
+        // 判断是否为空
+        if (false) {
+            returnMap.put("code", "-1");
+            returnMap.put("msg", "获取摄像头使用情况为空!");
+            returnMap.put("air_total", "0");
+            returnMap.put("air_on_total", "0");
+        } else {
+            returnMap.put("code", "200");
+            returnMap.put("msg", "获取摄像头使用情况成功!");
+            returnMap.put("projector_total", "100");
+            returnMap.put("projector_on_using", "200");
+        }
+
+        return returnMap;
+    }
+
+    @RequestMapping(value = "/getEquipmentUsage", method = RequestMethod.POST)
+    public ResponseResult getEquipmentUsage() {
+        Map<String, String> computerUsage = getComputerUsage();
+        Map<String, String> projectorUsage = getProjectorUsage();
+        Map<String, String> airUsage = getAirUsage();
+        HashMap<String, Object> returnMap = new HashMap<>();
+        returnMap.put("airUsage", airUsage);
+        returnMap.put("projectorUsage", projectorUsage);
+        returnMap.put("computerUsage", computerUsage);
+
+        return ResponseResult.success(returnMap);
+    }
+
+    /**
+     * 空调状况分析
+     * @return
+     */
+    @RequestMapping(value = "/getAirConditionAnalysis", method = RequestMethod.POST)
+    public ResponseResult airConditionAnalysis() {
+        // 数量
+        int num_of_online = 200;
+        int num_of_offline = 100;
+        int num_of_alarms = 20;
+        int total_equipment = num_of_online + num_of_alarms + num_of_offline;
+
+        Map<String, String> map = new HashMap<>();
+        map.put("num_of_online", String.valueOf(num_of_online));
+        map.put("num_of_offline", String.valueOf(num_of_offline));
+        map.put("num_of_alarms", String.valueOf(num_of_alarms));
+        map.put("total_equipment", String.valueOf(total_equipment));
+
+        return ResponseResult.success(map);
+    }
+
+    /**
      * 拉流,获取视频流地址
      * 拉流,获取视频流地址
      *
      *
      * @return
      * @return

+ 123 - 0
src/main/java/com/ch/jiaoxuelou_houtai/entity/EnvTesting.java

@@ -0,0 +1,123 @@
+package com.ch.jiaoxuelou_houtai.entity;
+
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.sql.Timestamp;
+
+public class EnvTesting {
+    private BigInteger id;
+    private String point_code;
+    private String point_name;
+    private String point_location;
+    private String temperature;
+    private String humidity;
+    private String negaticeO2Ion;
+    private String pm25;
+    private String pm10;
+    private String db;
+    private Timestamp update_time;
+
+    public EnvTesting(BigInteger id, String pointCode, String pointName, String pointLocation, String temperature,
+                      String humidity, String negaticeO2Ion, String pm25, String pm10, String db, Timestamp updateTime) {
+        this.id = id;
+        this.point_code = pointCode;
+        this.point_name = pointName;
+        this.point_location = pointLocation;
+        this.temperature = temperature;
+        this.humidity = humidity;
+        this.negaticeO2Ion = negaticeO2Ion;
+        this.pm25 = pm25;
+        this.pm10 = pm10;
+        this.db = db;
+        this.update_time = updateTime;
+    }
+
+    public BigInteger getId() {
+        return id;
+    }
+
+    public void setId(BigInteger id) {
+        this.id = id;
+    }
+
+    public String getPoint_code() {
+        return point_code;
+    }
+
+    public void setPoint_code(String point_code) {
+        this.point_code = point_code;
+    }
+
+    public String getPoint_name() {
+        return point_name;
+    }
+
+    public void setPoint_name(String point_name) {
+        this.point_name = point_name;
+    }
+
+    public String getPoint_location() {
+        return point_location;
+    }
+
+    public void setPoint_location(String point_location) {
+        this.point_location = point_location;
+    }
+
+    public String getTemperature() {
+        return temperature;
+    }
+
+    public void setTemperature(String temperature) {
+        this.temperature = temperature;
+    }
+
+    public String getHumidity() {
+        return humidity;
+    }
+
+    public void setHumidity(String humidity) {
+        this.humidity = humidity;
+    }
+
+    public String getNegaticeO2Ion() {
+        return negaticeO2Ion;
+    }
+
+    public void setNegaticeO2Ion(String negaticeO2Ion) {
+        this.negaticeO2Ion = negaticeO2Ion;
+    }
+
+    public String getPm25() {
+        return pm25;
+    }
+
+    public void setPm25(String pm25) {
+        this.pm25 = pm25;
+    }
+
+    public String getPm10() {
+        return pm10;
+    }
+
+    public void setPm10(String pm10) {
+        this.pm10 = pm10;
+    }
+
+    public String getDb() {
+        return db;
+    }
+
+    public void setDb(String db) {
+        this.db = db;
+    }
+
+    public Timestamp getUpdate_time() {
+        return update_time;
+    }
+
+    public void setUpdate_time(Timestamp update_time) {
+        this.update_time = update_time;
+    }
+}

+ 2 - 0
src/main/java/com/ch/jiaoxuelou_houtai/service/VideoService.java

@@ -15,4 +15,6 @@ public interface VideoService {
     JSONObject closeStreaming(String url, String requestBody, Map<String, String> headers);
     JSONObject closeStreaming(String url, String requestBody, Map<String, String> headers);
 
 
     JSONObject getAirOverTime(String url, Map<String, String> formData, Map<String, String> headers);
     JSONObject getAirOverTime(String url, Map<String, String> formData, Map<String, String> headers);
+
+    JSONObject getAirRealTime(String url, Map<String, String> headers);
 }
 }

+ 19 - 4
src/main/java/com/ch/jiaoxuelou_houtai/service/impl/VideoServiceImpl.java

@@ -21,7 +21,7 @@ public class VideoServiceImpl implements VideoService {
     public JSONObject login(String url, String requestBody, Map<String, String> headers) {
     public JSONObject login(String url, String requestBody, Map<String, String> headers) {
         // 调用封装的方法,发送http  post请求
         // 调用封装的方法,发送http  post请求
         OkHttpUtils okHttpUtils = new OkHttpUtils();
         OkHttpUtils okHttpUtils = new OkHttpUtils();
-        String s = okHttpUtils.post(url, requestBody, headers);
+        String s = okHttpUtils.postJson(url, requestBody, headers);
         // 返回json数据
         // 返回json数据
         return JSONObject.parse(s);
         return JSONObject.parse(s);
     }
     }
@@ -38,7 +38,7 @@ public class VideoServiceImpl implements VideoService {
     public JSONObject getVideoList(String url, String requestBody, Map<String, String> headers) {
     public JSONObject getVideoList(String url, String requestBody, Map<String, String> headers) {
         // 调用封装的方法,发送http  post请求
         // 调用封装的方法,发送http  post请求
         OkHttpUtils okHttpUtils = new OkHttpUtils();
         OkHttpUtils okHttpUtils = new OkHttpUtils();
-        String s = okHttpUtils.post(url, requestBody, headers);
+        String s = okHttpUtils.postJson(url, requestBody, headers);
         // 返回json数据
         // 返回json数据
         return JSONObject.parse(s);
         return JSONObject.parse(s);
     }
     }
@@ -59,6 +59,21 @@ public class VideoServiceImpl implements VideoService {
     }
     }
 
 
     /**
     /**
+     * 获取空调总数和在线数
+     *
+     * @param url
+     * @return
+     */
+    @Override
+    public JSONObject getAirRealTime(String url, Map<String, String> headers) {
+        // 调用封装的方法,发送http  post请求
+        OkHttpUtils okHttpUtils = new OkHttpUtils();
+        String s = okHttpUtils.post(url, headers);
+        // 返回json数据
+        return JSONObject.parse(s);
+    }
+
+    /**
      * 拉流,获取视频流地址
      * 拉流,获取视频流地址
      *
      *
      * @param url
      * @param url
@@ -70,7 +85,7 @@ public class VideoServiceImpl implements VideoService {
     public JSONObject openStreaming(String url, String json, Map<String, String> headers) {
     public JSONObject openStreaming(String url, String json, Map<String, String> headers) {
         // 调用封装的方法,发送http  post请求
         // 调用封装的方法,发送http  post请求
         OkHttpUtils okHttpUtils = new OkHttpUtils();
         OkHttpUtils okHttpUtils = new OkHttpUtils();
-        String s = okHttpUtils.post(url, json, headers);
+        String s = okHttpUtils.postJson(url, json, headers);
         // 返回json数据
         // 返回json数据
         return JSONObject.parse(s);
         return JSONObject.parse(s);
     }
     }
@@ -87,7 +102,7 @@ public class VideoServiceImpl implements VideoService {
     public JSONObject closeStreaming(String url, String json, Map<String, String> headers) {
     public JSONObject closeStreaming(String url, String json, Map<String, String> headers) {
         // 调用封装的方法,发送http  post请求
         // 调用封装的方法,发送http  post请求
         OkHttpUtils okHttpUtils = new OkHttpUtils();
         OkHttpUtils okHttpUtils = new OkHttpUtils();
-        String s = okHttpUtils.post(url, json, headers);
+        String s = okHttpUtils.postJson(url, json, headers);
         // 返回json数据
         // 返回json数据
         return JSONObject.parse(s);
         return JSONObject.parse(s);
     }
     }

+ 83 - 0
src/main/java/com/ch/jiaoxuelou_houtai/util/DbUtil.java

@@ -0,0 +1,83 @@
+package com.ch.jiaoxuelou_houtai.util;
+
+import com.ch.jiaoxuelou_houtai.entity.EnvTesting;
+
+import java.math.BigInteger;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DbUtil {
+
+    private static final String URL = "jdbc:mysql://172.16.20.45:3306/smartschool_bigdata?allowPublicKeyRetrieval=true&useSSL=false&connectTimeout=10000&socketTimeout=10000&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull";
+    private static final String USERNAME = "queryUser";
+    private static final String PASSWORD = "fcBtkT2EwCjiTdc4";
+
+    private static Connection getConnection() throws SQLException {
+        return DriverManager.getConnection(URL, USERNAME, PASSWORD);
+    }
+
+    public List<EnvTesting> executeQuery(String sql) {
+        Connection conn = null;
+        PreparedStatement stmt = null;
+        ResultSet rs = null;
+        List<EnvTesting> envTestings = new ArrayList<>();
+        try {
+            conn = getConnection();
+            stmt = conn.prepareStatement(sql);
+            rs = stmt.executeQuery();
+            while (rs.next()) {
+                BigInteger id = BigInteger.valueOf(rs.getInt("id"));
+                String point_code = rs.getString("point_code");
+                String point_name = rs.getString("point_name");
+                String point_location = rs.getString("point_location");
+                String temperature = rs.getString("temperature");
+                String humidity = rs.getString("humidity");
+                String negaticeO2Ion = rs.getString("negaticeO2Ion");
+                String pm25 = rs.getString("pm25");
+                String pm10 = rs.getString("pm10");
+                String db = rs.getString("db");
+                Timestamp update_time = rs.getTimestamp("update_time");
+                envTestings.add(new EnvTesting(id, point_code, point_name, point_location, temperature, humidity,
+                        negaticeO2Ion, pm25,pm10, db, update_time));
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        } finally {
+            closeResultSet(rs);
+            closeStatement(stmt);
+            closeConnection(conn);
+        }
+        return envTestings;
+    }
+
+    public static void closeConnection(Connection conn) {
+        if (conn != null) {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static void closeStatement(Statement stmt) {
+        if (stmt != null) {
+            try {
+                stmt.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static void closeResultSet(ResultSet rs) {
+        if (rs != null) {
+            try {
+                rs.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 49 - 6
src/main/java/com/ch/jiaoxuelou_houtai/util/OkHttpUtils.java

@@ -1,9 +1,11 @@
 package com.ch.jiaoxuelou_houtai.util;
 package com.ch.jiaoxuelou_houtai.util;
 
 
 import okhttp3.*;
 import okhttp3.*;
+import org.jetbrains.annotations.NotNull;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Map;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 
 public class OkHttpUtils {
 public class OkHttpUtils {
     private static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
     private static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
@@ -11,6 +13,41 @@ public class OkHttpUtils {
     private static final MediaType PLAIN_TEXT = MediaType.get("text/plain; charset=utf-8");
     private static final MediaType PLAIN_TEXT = MediaType.get("text/plain; charset=utf-8");
     private final OkHttpClient client = new OkHttpClient();
     private final OkHttpClient client = new OkHttpClient();
 
 
+    public CompletableFuture<String> makeAsyncRequest(String url) {
+        Request request = new Request.Builder()
+                .url(url)
+                .build();
+
+        CompletableFuture<String> future = new CompletableFuture<>();
+
+        client.newCall(request).enqueue(new Callback() {
+            @Override
+            public void onFailure(@NotNull Call call, IOException e) {
+                future.completeExceptionally(e);
+            }
+
+            @Override
+            public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+                String responseBody = null;
+                if (response.body() != null) {
+                    responseBody = response.body().string();
+                }
+                future.complete(responseBody);
+            }
+        });
+
+        return future;
+
+//        CompletableFuture<String> futureResult = myService.makeAsyncRequest();
+//
+//        try {
+//            String result = futureResult.get();
+//            System.out.println("Async request result: " + result);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+    }
+
     public String get(String url) {
     public String get(String url) {
         Request request = new Request.Builder()
         Request request = new Request.Builder()
                 .url(url)
                 .url(url)
@@ -51,14 +88,20 @@ public class OkHttpUtils {
         }
         }
     }
     }
 
 
-    public String post(String url) {
+    public String post(String url, Map<String,String> headers) {
         RequestBody body = RequestBody.create("", JSON);
         RequestBody body = RequestBody.create("", JSON);
 
 
-        Request request = new Request.Builder()
+        Request.Builder requestBuilder = new Request.Builder()
                 .url(url)
                 .url(url)
                 .header("Content-Type", "application/json")
                 .header("Content-Type", "application/json")
-                .post(body)
-                .build();
+                .post(body);
+
+        requestBuilder.addHeader("Content-Type", "application/json");
+        for (Map.Entry<String, String> entry : headers.entrySet()) {
+            requestBuilder.addHeader(entry.getKey(), entry.getValue());
+        }
+
+        Request request = requestBuilder.build();
 
 
         try (Response response = client.newCall(request).execute()) {
         try (Response response = client.newCall(request).execute()) {
             if (response.body() != null) {
             if (response.body() != null) {
@@ -71,7 +114,7 @@ public class OkHttpUtils {
         }
         }
     }
     }
 
 
-    public String post(String url, String json, Map<String,String> headers) {
+    public String postJson(String url, String json, Map<String,String> headers) {
         RequestBody body = RequestBody.create(json, JSON);
         RequestBody body = RequestBody.create(json, JSON);
 
 
         Request.Builder requestBuilder = new Request.Builder()
         Request.Builder requestBuilder = new Request.Builder()
@@ -144,7 +187,7 @@ public class OkHttpUtils {
         }
         }
     }
     }
 
 
-    public String post(String url, Map<String, String> formData, Map<String, String> jsonParams, Map<String, String> textParams) {
+    public String postJsonFormDataPlainText(String url, Map<String, String> formData, Map<String, String> jsonParams, Map<String, String> textParams) {
         MultipartBody.Builder formBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
         MultipartBody.Builder formBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
         for (Map.Entry<String, String> entry : formData.entrySet()) {
         for (Map.Entry<String, String> entry : formData.entrySet()) {
             formBuilder.addFormDataPart(entry.getKey(), entry.getValue());
             formBuilder.addFormDataPart(entry.getKey(), entry.getValue());

+ 0 - 7
src/main/resources/application.yml

@@ -5,13 +5,6 @@ server:
       timeout: 1440m
       timeout: 1440m
   port: 8088
   port: 8088
 
 
-modulea:
-  datasource:
-    url: jdbc:mysql://172.16.20.45:3306/martschool_bigdata?allowPublicKeyRetrieval=true&useSSL=false&connectTimeout=10000&socketTimeout=10000&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull
-    username: queryUser
-    password: fcBtkT2EwCjiTdc4
-
-
 spring:
 spring:
   datasource:
   datasource:
 #    username: root
 #    username: root