From 25fefe027bde1aad478fe0761e0a9e07da779ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Mon, 8 Jul 2024 10:19:09 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E6=B5=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DcTrafficStatisticsServiceImpl.java | 223 +++++++++++------- 1 file changed, 134 insertions(+), 89 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java index ea658dff..20713359 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java @@ -5,17 +5,16 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.spring.SpringUtils; -import com.sun.xml.bind.v2.TODO; import com.zc.business.constant.RedisKeyConstants; -import com.zc.business.domain.*; +import com.zc.business.domain.DcCongestionSection; +import com.zc.business.domain.DcFacility; +import com.zc.business.domain.DcRoadSection; +import com.zc.business.domain.DcRoadSectionCongestion; import com.zc.business.enums.StakeMarkRange; import com.zc.business.enums.UniversalEnum; import com.zc.business.service.IDcFacilityService; -import com.zc.business.service.IDcRoadConditionInformationService; import com.zc.business.service.IDcRoadSectionService; import com.zc.business.service.IDcTrafficStatisticsService; import com.zc.business.utils.StakeMarkUtils; @@ -28,7 +27,6 @@ import okhttp3.Response; import okhttp3.ResponseBody; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; @@ -119,7 +117,6 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi } */ - public static CompletableFuture refreshAccessToken() { CompletableFuture future = new CompletableFuture<>(); OkHttp okHttp = new OkHttp(); @@ -208,7 +205,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - return JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + } else { + return new JSONArray(); + } } return new JSONArray(); @@ -318,7 +320,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - return JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + } else { + return new JSONArray(); + } } return new JSONArray(); } @@ -563,7 +570,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - return JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + } else { + return new JSONArray(); + } } return new JSONArray(); @@ -604,7 +616,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - return JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + } else { + return new JSONArray(); + } } return new JSONArray(); @@ -642,7 +659,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - return JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + }else { + return new JSONArray(); + } } return new JSONArray(); @@ -684,12 +706,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi if (body != null) { JSONArray jsonArray = JSON.parseArray(body.string()); Map sumByName = new LinkedHashMap<>(); - Integer totalFlow1=0; + Integer totalFlow1 = 0; List> list = new ArrayList(); for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object JSONObject jsonObject = (JSONObject) item; - totalFlow1=totalFlow1+ jsonObject.getInteger("total_flow"); + totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow"); // 获取当前时间 LocalTime now = LocalTime.now(); @@ -702,7 +724,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi sumByName.put(name, totalFlow); } } - System.out.println("总数===:"+totalFlow1); + System.out.println("总数===:" + totalFlow1); // 正确创建新的映射对象并添加到list中 for (Map.Entry entry : sumByName.entrySet()) { Map singleResult = new LinkedHashMap<>(); // 每次循环都创建一个新的映射 @@ -746,7 +768,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - return JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + }else { + return new JSONArray(); + } } return new JSONArray(); @@ -866,8 +893,15 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi .data(requestParams) // 请求参数 .post(); // 请求方法 ResponseBody body = response.body(); - JSONArray jsonArray = JSON.parseArray(body.string()); - return jsonArray; + if (body != null) { + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + }else { + return new JSONArray(); + } + } + return new JSONArray(); } //格式化桩号 @@ -933,8 +967,9 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - JSONArray jsonArray = JSON.parseArray(body.string()); - System.out.println(jsonArray); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + JSONArray jsonArray = JSON.parseArray(jsonString); for (Object item : jsonArray) { JSONObject jsonObject = (JSONObject) item; if (jsonObject.getString("gantry_id").equals(nearestFacility.getFacilityCode())) { @@ -946,7 +981,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi mapList.add(map); } } - + } // 输出结果 return mapList; @@ -982,100 +1017,110 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - JSONArray jsonArray = JSON.parseArray(body.string()); - for (Object object : jsonArray) { - JSONObject jsonObject = (JSONObject) object; - Integer asOneRoad = jsonObject.getInteger("as_one_road"); - if (jsonObject.getDouble("end_pile_no")!=null){ - double endPileNo = jsonObject.getDouble("end_pile_no"); - String endMark = formatNumber(endPileNo); - jsonObject.put("endMark", endMark);//结束桩号 - } - double startPileNo = jsonObject.getDouble("start_pile_no"); - String stakeMark = formatNumber(startPileNo); - jsonObject.put("stakeMark", stakeMark);// - - //as_one_road - //是否为同一条路,1-是,0-否 - if (asOneRoad == UniversalEnum.ZERO.getNumber()) { - - String string = jsonObject.getString("list_link_info"); - JSONArray jsonlist = JSON.parseArray(string); - JSONObject o = (JSONObject) jsonlist.get(UniversalEnum.ZERO.getNumber()); - - String string1 = o.getString("firstPoint"); - String string2 = o.getString("lastPoint"); - String lngLats = o.getString("lngLats"); - String[] lngLatsString = lngLats.split(";"); - double s = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]); - double s2 = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]); - double s3 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]); - double s4 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]); - double distanceM = calculateDistance(s2, s, s4, s3); - // System.out.printf("最大距离为: %.2f 米%n", distanceM); - jsonObject.put("max_jam_dist", distanceM);//最大拥堵距离 - double endMake = startPileNo +Double.parseDouble(String.format("%.3f", distanceM)); - String endmark = formatNumber(endMake); - jsonObject.put("endMark", endmark);//结束桩号 - - String[] split = string1.split(","); - double firstLon = Double.parseDouble(split[UniversalEnum.ZERO.getNumber()]); - double firstLat = Double.parseDouble(split[UniversalEnum.ONE.getNumber()]); - String[] split2 = string2.split(","); - double lastLon = Double.parseDouble(split2[UniversalEnum.ZERO.getNumber()]); - double lastLat = Double.parseDouble(split2[UniversalEnum.ONE.getNumber()]); - //double firstLat = 35.38524527319016; - // double firstLon = 118.39808642864227; - //double lastLat = 35.386351346969604; - // double lastLon = 118.4038907289505; - double distanceKm = calculateDistance(firstLat, firstLon, lastLat, lastLon); - double distanceMeters = distanceKm * UniversalEnum.THOUSAND.getNumber(); // 将距离转换为米 - //System.out.printf("两点之间的距离为: %.2f 米%n", distanceMeters); - jsonObject.put("jam_dist", distanceMeters);//当前拥堵距离 + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + JSONArray jsonArray = JSON.parseArray(jsonString); + for (Object object : jsonArray) { + JSONObject jsonObject = (JSONObject) object; + Integer asOneRoad = jsonObject.getInteger("as_one_road"); + if (jsonObject.getDouble("end_pile_no") != null) { + double endPileNo = jsonObject.getDouble("end_pile_no"); + String endMark = formatNumber(endPileNo); + jsonObject.put("endMark", endMark);//结束桩号 + } + double startPileNo = jsonObject.getDouble("start_pile_no"); + String stakeMark = formatNumber(startPileNo); + jsonObject.put("stakeMark", stakeMark);// + + //as_one_road + //是否为同一条路,1-是,0-否 + if (asOneRoad == UniversalEnum.ZERO.getNumber()) { + + String string = jsonObject.getString("list_link_info"); + JSONArray jsonlist = JSON.parseArray(string); + JSONObject o = (JSONObject) jsonlist.get(UniversalEnum.ZERO.getNumber()); + + String string1 = o.getString("firstPoint"); + String string2 = o.getString("lastPoint"); + String lngLats = o.getString("lngLats"); + String[] lngLatsString = lngLats.split(";"); + double s = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]); + double s2 = Double.parseDouble(lngLatsString[UniversalEnum.ZERO.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]); + double s3 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ZERO.getNumber()]); + double s4 = Double.parseDouble(lngLatsString[lngLatsString.length - UniversalEnum.ONE.getNumber()].split(",")[UniversalEnum.ONE.getNumber()]); + double distanceM = calculateDistance(s2, s, s4, s3); + // System.out.printf("最大距离为: %.2f 米%n", distanceM); + jsonObject.put("max_jam_dist", distanceM);//最大拥堵距离 + double endMake = startPileNo + Double.parseDouble(String.format("%.3f", distanceM)); + String endmark = formatNumber(endMake); + jsonObject.put("endMark", endmark);//结束桩号 + + String[] split = string1.split(","); + double firstLon = Double.parseDouble(split[UniversalEnum.ZERO.getNumber()]); + double firstLat = Double.parseDouble(split[UniversalEnum.ONE.getNumber()]); + String[] split2 = string2.split(","); + double lastLon = Double.parseDouble(split2[UniversalEnum.ZERO.getNumber()]); + double lastLat = Double.parseDouble(split2[UniversalEnum.ONE.getNumber()]); + //double firstLat = 35.38524527319016; + // double firstLon = 118.39808642864227; + //double lastLat = 35.386351346969604; + // double lastLon = 118.4038907289505; + double distanceKm = calculateDistance(firstLat, firstLon, lastLat, lastLon); + double distanceMeters = distanceKm * UniversalEnum.THOUSAND.getNumber(); // 将距离转换为米 + //System.out.printf("两点之间的距离为: %.2f 米%n", distanceMeters); + jsonObject.put("jam_dist", distanceMeters);//当前拥堵距离 + } } - } - - return jsonArray; + return jsonArray; + } } return new JSONArray(); } + /** * 各收费站日累计车流辆 + * * @return */ @Override - public int trafficFlowAtToll()throws HttpException, IOException { + public int trafficFlowAtToll() throws HttpException, IOException { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); LocalDate currentDate = LocalDate.now(); String startDate = currentDate.format(formatter); - Response response = getResponseTrafficFlowAtToll(startDate,UniversalEnum.ONE.getValue()); - Response responseTwo = getResponseTrafficFlowAtToll(startDate,UniversalEnum.TWO.getValue()); + Response response = getResponseTrafficFlowAtToll(startDate, UniversalEnum.ONE.getValue()); + Response responseTwo = getResponseTrafficFlowAtToll(startDate, UniversalEnum.TWO.getValue()); ResponseBody body = response.body(); ResponseBody bodyTwo = responseTwo.body(); - Integer totalFlow1=UniversalEnum.ZERO.getNumber(); - Integer totalFlow2=UniversalEnum.ZERO.getNumber(); + Integer totalFlow1 = UniversalEnum.ZERO.getNumber(); + Integer totalFlow2 = UniversalEnum.ZERO.getNumber(); if (body != null) { - JSONArray jsonArray = JSON.parseArray(body.string()); - for (Object item : jsonArray) { - JSONObject jsonObject = (JSONObject) item; - totalFlow1=totalFlow1+ jsonObject.getInteger("total_flow"); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + JSONArray jsonArray = JSON.parseArray(jsonString); + for (Object item : jsonArray) { + JSONObject jsonObject = (JSONObject) item; + totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow"); + } } } if (bodyTwo != null) { - JSONArray jsonArray = JSON.parseArray(bodyTwo.string()); - for (Object item : jsonArray) { - JSONObject jsonObject = (JSONObject) item; - totalFlow2=totalFlow2+ jsonObject.getInteger("total_flow"); + String jsonString = bodyTwo.string(); + if (JSON.isValidArray(jsonString)) { + JSONArray jsonArray = JSON.parseArray(jsonString); + for (Object item : jsonArray) { + JSONObject jsonObject = (JSONObject) item; + totalFlow2 = totalFlow2 + jsonObject.getInteger("total_flow"); + } } } - return totalFlow1+totalFlow2; + return totalFlow1 + totalFlow2; } - private Response getResponseTrafficFlowAtToll(String startDate,String stationType) throws HttpException, IOException { + private Response getResponseTrafficFlowAtToll(String startDate, String stationType) throws HttpException, IOException { OkHttp okHttp = new OkHttp(); RequestParams requestParams = new RequestParams(); From 11483d91f1735653ada1737a717e44ddad24469a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Mon, 8 Jul 2024 10:24:58 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E6=B5=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DcTrafficStatisticsServiceImpl.java | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java index 20713359..266475e9 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java @@ -243,7 +243,10 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi JSONArray jsonArray = null; if (body != null) { - jsonArray = JSON.parseArray(body.string()); + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + jsonArray = JSON.parseArray(jsonString); + } } Map map = new HashMap<>(); @@ -704,37 +707,39 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi ResponseBody body = response.body(); if (body != null) { - JSONArray jsonArray = JSON.parseArray(body.string()); - Map sumByName = new LinkedHashMap<>(); - Integer totalFlow1 = 0; - List> list = new ArrayList(); - for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object - JSONObject jsonObject = (JSONObject) item; + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + JSONArray jsonArray = JSON.parseArray(jsonString); + Map sumByName = new LinkedHashMap<>(); + Integer totalFlow1 = 0; + List> list = new ArrayList(); + for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object + JSONObject jsonObject = (JSONObject) item; - totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow"); + totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow"); - // 获取当前时间 - LocalTime now = LocalTime.now(); - // 获取当前小时数(24小时制) - int currentHour = now.getHour(); - if (jsonObject.getInteger("data_hour") == currentHour) { - String name = jsonObject.getString("ts_name"); // 更安全的取值方式 - int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型 + // 获取当前时间 + LocalTime now = LocalTime.now(); + // 获取当前小时数(24小时制) + int currentHour = now.getHour(); + if (jsonObject.getInteger("data_hour") == currentHour) { + String name = jsonObject.getString("ts_name"); // 更安全的取值方式 + int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型 - sumByName.put(name, totalFlow); + sumByName.put(name, totalFlow); + } } + System.out.println("总数===:" + totalFlow1); + // 正确创建新的映射对象并添加到list中 + for (Map.Entry entry : sumByName.entrySet()) { + Map singleResult = new LinkedHashMap<>(); // 每次循环都创建一个新的映射 + singleResult.put("name", entry.getKey()); + singleResult.put("value", entry.getValue().toString()); + list.add(singleResult); + } + return list; } - System.out.println("总数===:" + totalFlow1); - // 正确创建新的映射对象并添加到list中 - for (Map.Entry entry : sumByName.entrySet()) { - Map singleResult = new LinkedHashMap<>(); // 每次循环都创建一个新的映射 - singleResult.put("name", entry.getKey()); - singleResult.put("value", entry.getValue().toString()); - list.add(singleResult); - } - return list; } - return new ArrayList(); } From 058c64257f8ece4268b0aa1789490440f5a21cd1 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Mon, 8 Jul 2024 11:46:30 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E6=B5=81=E7=9B=91=E6=B5=8B=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/ExternalInterfaceMonitoring.java | 2 ++ .../task/ExternalInterfaceMonitoringTask.java | 35 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java b/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java index 762a53d6..cddd3a76 100644 --- a/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java +++ b/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java @@ -1,5 +1,6 @@ package com.zc.business.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -41,6 +42,7 @@ public class ExternalInterfaceMonitoring { @ApiModelProperty("操作结果") private String operationResult; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") @ApiModelProperty("操作时间") private Date operationTime; } diff --git a/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java b/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java index e44df653..b52fc60e 100644 --- a/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java +++ b/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java @@ -7,6 +7,9 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; @@ -71,8 +74,7 @@ public class ExternalInterfaceMonitoringTask extends BaseController { */ @ApiOperation("外部接口监控信息列表") @GetMapping("/list") - public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) - { + public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) { startPage(); LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); if (externalInterfaceMonitoring.getInterfaceOwnership() != null) { @@ -578,10 +580,10 @@ public class ExternalInterfaceMonitoringTask extends BaseController { externalInterfaceMonitoring.setOperationResult(response.toString()); } - }catch (Exception e) { + } catch (Exception e) { externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); externalInterfaceMonitoring.setOperationResult(e.toString()); - }finally { + } finally { externalInterfaceMonitoring.setId(IdUtils.fastSimpleUUID()); externalInterfaceMonitoring.setOperatorName("系统"); externalInterfaceMonitoring.setOperationTime(new Date()); @@ -594,15 +596,30 @@ public class ExternalInterfaceMonitoringTask extends BaseController { * 交通流结果处理 */ public void trafficFlowResultProcessing(ExternalInterfaceMonitoring externalInterfaceMonitoring, Response response) throws Exception { + ResponseBody body = response.body(); - externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + if (response.code() == UniversalEnum.TWO_HUNDRED.getNumber()) { + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); + } else { + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + } + if (body != null) { - JSONObject jsonResult = JSONObject.parseObject(body.string()); - if (jsonResult.containsKey("code") && jsonResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { - externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ONE.getNumber()); + String bodyString = body.string(); + JsonObject jsonResult = null; + // 使用JsonElement解析数据 + JsonElement jsonElement = JsonParser.parseString(bodyString); + + // 检查数据类型并相应处理 + if (jsonElement.isJsonObject()) { + // 如果是对象,进行对象处理 + jsonResult = jsonElement.getAsJsonObject(); + if (!jsonResult.get("code").toString().equals(UniversalEnum.TWO_HUNDRED.getValue())) { + externalInterfaceMonitoring.setOperationStatus(UniversalEnum.ZERO.getNumber()); + } } - externalInterfaceMonitoring.setOperationResult(body.string()); + externalInterfaceMonitoring.setOperationResult(bodyString); } else { externalInterfaceMonitoring.setOperationResult(response.toString()); } From 65d95ba62c70c8fe4fd5d4d3db18a9ecfd4a7552 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 8 Jul 2024 11:47:14 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=9C=A8=E7=BA=BF=E7=8E=87=E5=88=86=E6=9E=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/StatusController.java | 6 +- .../com/zc/business/enums/UniversalEnum.java | 16 +- .../service/impl/ExcelExportService.java | 199 ++++++++++-------- 3 files changed, 125 insertions(+), 96 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/StatusController.java b/zc-business/src/main/java/com/zc/business/controller/StatusController.java index e7ac9b3d..9ab72129 100644 --- a/zc-business/src/main/java/com/zc/business/controller/StatusController.java +++ b/zc-business/src/main/java/com/zc/business/controller/StatusController.java @@ -267,6 +267,8 @@ public class StatusController extends BaseController { itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); + itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.SOLAR_PANEL.getValue()); + itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.REMOTE_COMPUTER.getValue()); LocalDateTime todayStart = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS); LocalDateTime currentTime = LocalDateTime.now(); Status status = new Status(); @@ -394,7 +396,9 @@ public class StatusController extends BaseController { UniversalEnum.LASER_FATIGUE_AWAKENING.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue(), - UniversalEnum.SMART_DEVICE_BOX.getValue() + UniversalEnum.SMART_DEVICE_BOX.getValue(), + UniversalEnum.SOLAR_PANEL.getValue(), + UniversalEnum.REMOTE_COMPUTER.getValue() }; orderRule= Arrays.toString(rules).replace(UniversalEnum.LEFT_CENTER_BRACKET.getValue(),UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.CLOSE_CENTER_BRACKET.getValue(),UniversalEnum.EMPTY_STRING.getValue()).replace(UniversalEnum.BLANK_SPACE.getValue(),UniversalEnum.EMPTY_STRING.getValue()); ruleMap.put("rule",orderRule); diff --git a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java index 4fcf7c24..5282ab65 100644 --- a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java +++ b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java @@ -338,10 +338,16 @@ public enum UniversalEnum { ROAD_SECTION_NAME(0, "路段名称"), // 菏泽方向 - DIRECTION_OF_HEZE(0, "菏泽方向"), + DIRECTION_OF_HEZE(1, "菏泽方向"), + + // 双向 + BIDIRECTIONAL(2, "双向"), // 济南方向 - DIRECTION_OF_JINAN(0, "济南方向"), + DIRECTION_OF_JINAN(3, "济南方向"), + + // 未知方向 + UNKNOWN_DIRECTION(4, "未知方向"), // 上行 Up(0, "上行"), @@ -409,6 +415,12 @@ public enum UniversalEnum { //智能设备箱 SMART_DEVICE_BOX(0, "智能设备箱"), + //太阳能板 + SOLAR_PANEL(0, "太阳能板"), + + //远端机 + REMOTE_COMPUTER(0, "远端机"), + //设备名称 DEVICE_NAME(0, "设备名称"), diff --git a/zc-business/src/main/java/com/zc/business/service/impl/ExcelExportService.java b/zc-business/src/main/java/com/zc/business/service/impl/ExcelExportService.java index 82daa086..913f3ef5 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/ExcelExportService.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/ExcelExportService.java @@ -17,7 +17,7 @@ import java.util.stream.Collectors; @Service public class ExcelExportService { - public void exportDataToExcel(Map> ipMap, Map >categoryMap, String filePath) { + public void exportDataToExcel(Map> ipMap, Map> categoryMap, String filePath) { Workbook workbook = new XSSFWorkbook(); Map> map = new TreeMap<>(ipMap); Sheet sheet = workbook.createSheet(UniversalEnum.DEVICE_FAILURE_RATE_TIME_SHARING_STATISTICS_PAGE.getValue()); @@ -37,41 +37,50 @@ public class ExcelExportService { sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.FOUR.getNumber(), UniversalEnum.FOUR.getNumber())); sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.FIVE.getNumber(), UniversalEnum.FIVE.getNumber())); sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.SIX.getNumber(), UniversalEnum.SIX.getNumber())); - int i=UniversalEnum.ZERO.getNumber(); - boolean flag = true; - Row row1= sheet.createRow(UniversalEnum.ONE.getNumber()); + int i = UniversalEnum.ZERO.getNumber(); + boolean flag = true; + Row row1 = sheet.createRow(UniversalEnum.ONE.getNumber()); for (Map.Entry> entry : map.entrySet()) { - row0.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber()).setCellValue(entry.getKey()+UniversalEnum.HOUR.getValue()); - sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber(), UniversalEnum.TWO.getNumber()*i+UniversalEnum.EIGHT.getNumber())); - row1.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber()).setCellValue(UniversalEnum.ONLINE_RATE.getValue()); - row1.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.EIGHT.getNumber()).setCellValue(UniversalEnum.PACKET_LOSS_RATE.getValue()); + row0.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber()).setCellValue(entry.getKey() + UniversalEnum.HOUR.getValue()); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber(), UniversalEnum.TWO.getNumber() * i + UniversalEnum.EIGHT.getNumber())); + row1.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber()).setCellValue(UniversalEnum.ONLINE_RATE.getValue()); + row1.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.EIGHT.getNumber()).setCellValue(UniversalEnum.PACKET_LOSS_RATE.getValue()); rowNum = UniversalEnum.TWO.getNumber(); - List groupItems = entry.getValue(); - for (Status ignored : groupItems) { - int a=rowNum++; - Row row = sheet.getRow(a); // 获取指定索引的行 - if (row == null) { // 如果行不存在,则创建新行 - row = sheet.createRow(a); - } - if(flag) { - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceName()); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceIp()); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceNo()); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDirection()); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getProduction()); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getModel()); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getContent()); + List groupItems = entry.getValue(); + for (Status ignored : groupItems) { + int a = rowNum++; + Row row = sheet.getRow(a); // 获取指定索引的行 + if (row == null) { // 如果行不存在,则创建新行 + row = sheet.createRow(a); + } + if (flag) { + row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceName()); + row.createCell(UniversalEnum.ONE.getNumber()).setCellValue(ignored.getDeviceIp()); + row.createCell(UniversalEnum.TWO.getNumber()).setCellValue(ignored.getDeviceNo()); + Integer direction = Integer.parseInt(ignored.getDirection() != null ? ignored.getDirection() : UniversalEnum.FOUR.getValue()); + String directionDescription = UniversalEnum.UNKNOWN_DIRECTION.getValue(); + if (Objects.equals(direction, UniversalEnum.DIRECTION_OF_HEZE.getNumber())) { + directionDescription = UniversalEnum.DIRECTION_OF_HEZE.getValue(); + } else if (Objects.equals(direction, UniversalEnum.BIDIRECTIONAL.getNumber())) { + directionDescription = UniversalEnum.BIDIRECTIONAL.getValue(); + } else if (Objects.equals(direction, UniversalEnum.DIRECTION_OF_JINAN.getNumber())) { + directionDescription = UniversalEnum.DIRECTION_OF_JINAN.getValue(); } - row.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber()).setCellValue(ignored.getSuccessRate()); - row.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.EIGHT.getNumber()).setCellValue(ignored.getLostRate()); + row.createCell(UniversalEnum.THREE.getNumber()).setCellValue(directionDescription); + row.createCell(UniversalEnum.FOUR.getNumber()).setCellValue(ignored.getProduction()); + row.createCell(UniversalEnum.FIVE.getNumber()).setCellValue(ignored.getModel()); + row.createCell(UniversalEnum.SIX.getNumber()).setCellValue(ignored.getContent()); + } + row.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber()).setCellValue(ignored.getSuccessRate()); + row.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.EIGHT.getNumber()).setCellValue(ignored.getLostRate()); } i++; - flag = false; + //flag = false; } Sheet sheets = workbook.createSheet(UniversalEnum.DEVICE_FAILURE_RATE_SUMMARY_PAGE.getValue()); - createSheet(sheets,categoryMap); + createSheet(sheets, categoryMap); Sheet sheet1 = workbook.createSheet(UniversalEnum.EQUIPMENT_FAILURE_RATE_TIME_SHARING_SUMMARY_PAGE.getValue()); - createSheet1(sheet1,ipMap); + createSheet1(sheet1, ipMap); try (FileOutputStream outputStream = new FileOutputStream(filePath)) { workbook.write(outputStream); } catch (IOException e) { @@ -80,15 +89,16 @@ public class ExcelExportService { System.out.println("excel写入成功!!!!!!"); } - public void createSheet1(Sheet sheet,Map> ipMap){ + + public void createSheet1(Sheet sheet, Map> ipMap) { Map> map = new TreeMap<>(ipMap); int rowNum = UniversalEnum.ZERO.getNumber(); Row row0 = sheet.createRow(rowNum); row0.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(UniversalEnum.EQUIPMENT_CLASSIFICATION.getValue()); sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber())); - int i=UniversalEnum.ZERO.getNumber(); - boolean flag = true; - Row row1= sheet.createRow(UniversalEnum.ONE.getNumber()); + int i = UniversalEnum.ZERO.getNumber(); + boolean flag = true; + Row row1 = sheet.createRow(UniversalEnum.ONE.getNumber()); for (Map.Entry> entry : map.entrySet()) { row0.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.ONE.getNumber()).setCellValue(entry.getKey() + UniversalEnum.HOUR.getNumber()); sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.THREE.getNumber() * i + UniversalEnum.ONE.getNumber(), UniversalEnum.THREE.getNumber() * i + UniversalEnum.THREE.getNumber())); @@ -102,46 +112,49 @@ public class ExcelExportService { List groupItems = entrys.getValue(); long b = groupItems.stream().filter(iteam -> Objects.equals(iteam.getDeviceStatus(), UniversalEnum.ONE.getValue())).count(); // for (Status ignored : groupItems) { - int a = rowNum++; - Row row = sheet.getRow(a); // 获取指定索引的行 - if (row == null) { // 如果行不存在,则创建新行 - row = sheet.createRow(a); - } - HashMap itemTypeMap = new HashMap<>(); - itemTypeMap.put(UniversalEnum.ONE_ONE.getValue(), UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.ONE_TWO.getValue(), UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.ONE_THREE.getValue(), UniversalEnum.UNDER_THE_BRIDGE_HD_NETWORK_SPHERICAL_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.ONE_FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.ONE_FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.TWO_ONE.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); - itemTypeMap.put(UniversalEnum.TWO_THREE.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); - itemTypeMap.put(UniversalEnum.TWO_FOUR.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); - itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); - itemTypeMap.put(UniversalEnum.FIVE.getValue(), UniversalEnum.SECTION_VOICE_BROADCAST_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.SIX.getValue(), UniversalEnum.GUARDRAIL_COLLISION_WARNING_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.SEVEN.getValue(), UniversalEnum.MILLIMETER_WAVE_RADAR.getValue()); - itemTypeMap.put(UniversalEnum.EIGHT.getValue(), UniversalEnum.CONFLUENCE_AREA_EARLY_WARNING_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.TEN.getValue(), UniversalEnum.LASER_FATIGUE_AWAKENING.getValue()); - itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); - itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); - String type = groupItems.get(UniversalEnum.ZERO.getNumber()).getType(); - String description = itemTypeMap.get(type); - if (flag) { - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(description); - } - row.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.ONE.getNumber()).setCellValue(groupItems.size()); - row.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.TWO.getNumber()).setCellValue(b); - row.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.THREE.getNumber()).setCellValue(String.format("%.2f%%", (double) b / groupItems.size() * UniversalEnum.ONE_HUNDRED.getNumber())); + int a = rowNum++; + Row row = sheet.getRow(a); // 获取指定索引的行 + if (row == null) { // 如果行不存在,则创建新行 + row = sheet.createRow(a); } - i++; - flag = false; - // } + HashMap itemTypeMap = new HashMap<>(); + itemTypeMap.put(UniversalEnum.ONE_ONE.getValue(), UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_TWO.getValue(), UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_THREE.getValue(), UniversalEnum.UNDER_THE_BRIDGE_HD_NETWORK_SPHERICAL_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.TWO_ONE.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); + itemTypeMap.put(UniversalEnum.TWO_TWO.getValue(), UniversalEnum.VARIABLE_MESSAGE_SIGN_IN_FRONT_OF_STATION.getValue()); + itemTypeMap.put(UniversalEnum.TWO_THREE.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); + itemTypeMap.put(UniversalEnum.TWO_FOUR.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); + itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); + itemTypeMap.put(UniversalEnum.FIVE.getValue(), UniversalEnum.SECTION_VOICE_BROADCAST_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.SIX.getValue(), UniversalEnum.GUARDRAIL_COLLISION_WARNING_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.SEVEN.getValue(), UniversalEnum.MILLIMETER_WAVE_RADAR.getValue()); + itemTypeMap.put(UniversalEnum.EIGHT.getValue(), UniversalEnum.CONFLUENCE_AREA_EARLY_WARNING_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.TEN.getValue(), UniversalEnum.LASER_FATIGUE_AWAKENING.getValue()); + itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); + itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); + itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.SOLAR_PANEL.getValue()); + itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.REMOTE_COMPUTER.getValue()); + String type = groupItems.get(UniversalEnum.ZERO.getNumber()).getType(); + String description = itemTypeMap.get(type); + if (flag) { + row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(description); + } + row.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.ONE.getNumber()).setCellValue(groupItems.size()); + row.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.TWO.getNumber()).setCellValue(b); + row.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.THREE.getNumber()).setCellValue(String.format("%.2f%%", (double) b / groupItems.size() * UniversalEnum.ONE_HUNDRED.getNumber())); + } + i++; + flag = false; + // } } } - public void createSheet(Sheet sheet,Map >categoryMap){ + public void createSheet(Sheet sheet, Map> categoryMap) { int rowNum = UniversalEnum.ZERO.getNumber(); Row row = sheet.createRow(rowNum); row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(UniversalEnum.EQUIPMENT_CLASSIFICATION.getValue()); @@ -151,40 +164,40 @@ public class ExcelExportService { rowNum = UniversalEnum.ONE.getNumber(); for (Map.Entry> entry : categoryMap.entrySet()) { List groupItems = entry.getValue(); - long a=groupItems.stream().filter(iteam-> Objects.equals(iteam.getDeviceStatus(), UniversalEnum.ONE.getValue())).count(); - row = sheet.createRow(rowNum++); + long a = groupItems.stream().filter(iteam -> Objects.equals(iteam.getDeviceStatus(), UniversalEnum.ONE.getValue())).count(); + row = sheet.createRow(rowNum++); HashMap itemTypeMap = new HashMap<>(); - itemTypeMap.put(UniversalEnum.ONE.getValue(), UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.TWO.getValue(), UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.UNDER_THE_BRIDGE_HD_NETWORK_SPHERICAL_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); - itemTypeMap.put(UniversalEnum.SIX.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); - itemTypeMap.put(UniversalEnum.SEVEN.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); - itemTypeMap.put(UniversalEnum.EIGHT.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); - itemTypeMap.put(UniversalEnum.NINE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); - itemTypeMap.put(UniversalEnum.TEN.getValue(), UniversalEnum.SECTION_VOICE_BROADCAST_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.GUARDRAIL_COLLISION_WARNING_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.MILLIMETER_WAVE_RADAR.getValue()); - itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.CONFLUENCE_AREA_EARLY_WARNING_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.FOURTEEN.getValue(), UniversalEnum.LASER_FATIGUE_AWAKENING.getValue()); - itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); - itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); - itemTypeMap.put(UniversalEnum.SEVENTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); + itemTypeMap.put(UniversalEnum.ONE_ONE.getValue(), UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_TWO.getValue(), UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_THREE.getValue(), UniversalEnum.UNDER_THE_BRIDGE_HD_NETWORK_SPHERICAL_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.ONE_FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); + itemTypeMap.put(UniversalEnum.TWO_ONE.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); + itemTypeMap.put(UniversalEnum.TWO_TWO.getValue(), UniversalEnum.VARIABLE_MESSAGE_SIGN_IN_FRONT_OF_STATION.getValue()); + itemTypeMap.put(UniversalEnum.TWO_THREE.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); + itemTypeMap.put(UniversalEnum.TWO_FOUR.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); + itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); + itemTypeMap.put(UniversalEnum.FIVE.getValue(), UniversalEnum.SECTION_VOICE_BROADCAST_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.SIX.getValue(), UniversalEnum.GUARDRAIL_COLLISION_WARNING_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.SEVEN.getValue(), UniversalEnum.MILLIMETER_WAVE_RADAR.getValue()); + itemTypeMap.put(UniversalEnum.EIGHT.getValue(), UniversalEnum.CONFLUENCE_AREA_EARLY_WARNING_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.TEN.getValue(), UniversalEnum.LASER_FATIGUE_AWAKENING.getValue()); + itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); + itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); + itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); + itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.SOLAR_PANEL.getValue()); + itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.REMOTE_COMPUTER.getValue()); String type = groupItems.get(UniversalEnum.ZERO.getNumber()).getType(); String description = itemTypeMap.get(type); - row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(description); - row.createCell(UniversalEnum.ONE.getNumber()).setCellValue(groupItems.size()); - row.createCell(UniversalEnum.TWO.getNumber()).setCellValue(a); - row.createCell(UniversalEnum.THREE.getNumber()).setCellValue(String.format("%.2f%%", (double) a / groupItems.size() * UniversalEnum.ONE_HUNDRED.getNumber())); + row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(description); + row.createCell(UniversalEnum.ONE.getNumber()).setCellValue(groupItems.size()); + row.createCell(UniversalEnum.TWO.getNumber()).setCellValue(a); + row.createCell(UniversalEnum.THREE.getNumber()).setCellValue(String.format("%.2f%%", (double) a / groupItems.size() * UniversalEnum.ONE_HUNDRED.getNumber())); } } - - - } From 951f5972f63f793d5d57d716090e1592ca4d5c25 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Mon, 8 Jul 2024 14:21:52 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/monitor/Interface/index.vue | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 ruoyi-ui/src/views/monitor/Interface/index.vue diff --git a/ruoyi-ui/src/views/monitor/Interface/index.vue b/ruoyi-ui/src/views/monitor/Interface/index.vue new file mode 100644 index 00000000..c3368a90 --- /dev/null +++ b/ruoyi-ui/src/views/monitor/Interface/index.vue @@ -0,0 +1,170 @@ + + + From cb73f1e5c271d277f85c4565ed0cd77b3f911c93 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Mon, 8 Jul 2024 16:03:05 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9B=91=E6=B5=8B=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/monitor/Interface/index.vue | 33 +++++++++- .../domain/ExternalInterfaceMonitoring.java | 37 ++++++++++- .../task/ExternalInterfaceMonitoringTask.java | 61 ++++++++++++++++++- 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/ruoyi-ui/src/views/monitor/Interface/index.vue b/ruoyi-ui/src/views/monitor/Interface/index.vue index c3368a90..66b89320 100644 --- a/ruoyi-ui/src/views/monitor/Interface/index.vue +++ b/ruoyi-ui/src/views/monitor/Interface/index.vue @@ -28,9 +28,22 @@ /> + + + + 搜索 重置 + 导出 @@ -114,7 +127,10 @@ export default { pageSize: 10, interfaceOwnership: undefined, interfaceName: undefined, - operationStatus: undefined + operationStatus: undefined, + dateTime: undefined, + startTime: undefined, + endTime: undefined }, interfaceData: [], interfaceResult: undefined, @@ -163,6 +179,21 @@ export default { handleClose() { this.openView = false this.interfaceResult = undefined + }, + + /** 处理时间选择器组件 */ + handleProcessingTime() { + if (this.queryParams.dateTime.length > 0) { + this.queryParams.startTime = this.queryParams.dateTime[0] + this.queryParams.endTime = this.queryParams.dateTime[1] + } + }, + + /** 导出按钮操作 */ + handleExport() { + this.download('/externalInterface/export', { + ...this.queryParams + }, '外部接口监测.xlsx') } } diff --git a/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java b/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java index cddd3a76..35f99ae8 100644 --- a/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java +++ b/zc-business/src/main/java/com/zc/business/domain/ExternalInterfaceMonitoring.java @@ -1,6 +1,8 @@ package com.zc.business.domain; +import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -30,19 +32,48 @@ public class ExternalInterfaceMonitoring { @ApiModelProperty("接口所属") private Integer interfaceOwnership; + @Excel(name = "接口所属名称") + @TableField(exist = false) + @ApiModelProperty("接口所属名称") + private String interfaceOwnershipName; + + @Excel(name = "接口名称") @ApiModelProperty("接口名称") private String interfaceName; + @Excel(name = "操作人") @ApiModelProperty("操作人") private String operatorName; + @Excel(name = "操作状态") + @TableField(exist = false) + @ApiModelProperty("操作状态名称") + private String operationStatusName; + @ApiModelProperty("操作状态") private Integer operationStatus; - @ApiModelProperty("操作结果") - private String operationResult; - + @Excel(name = "操作时间",dateFormat = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") @ApiModelProperty("操作时间") private Date operationTime; + + @Excel(name = "操作结果") + @ApiModelProperty("操作结果") + private String operationResult; + + /** + * 开始时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(exist = false) + @ApiModelProperty("开始时间") + private Date startTime; + /** + * 结束时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(exist = false) + @ApiModelProperty("结束时间") + private Date endTime; } diff --git a/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java b/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java index b52fc60e..8c6aa902 100644 --- a/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java +++ b/zc-business/src/main/java/com/zc/business/task/ExternalInterfaceMonitoringTask.java @@ -14,6 +14,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.service.ISysConfigService; import com.zc.business.controller.DcNmcController; @@ -29,14 +30,19 @@ import com.zc.common.core.httpclient.request.RequestParams; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import okhttp3.*; +import org.apache.poi.ss.SpreadsheetVersion; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; @@ -76,6 +82,30 @@ public class ExternalInterfaceMonitoringTask extends BaseController { @GetMapping("/list") public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) { startPage(); + List list = selectExternal(externalInterfaceMonitoring); + return getDataTable(list); + } + + /** + * 外部接口监测数据导出 + */ + @PostMapping("/export") + public void export(HttpServletResponse response, ExternalInterfaceMonitoring externalInterfaceMonitoring) throws UnsupportedEncodingException { + List list = selectExternal(externalInterfaceMonitoring); + list.forEach(external -> { + external.setOperationStatusName(external.getOperationStatus().equals(UniversalEnum.ONE.getNumber()) ? "成功" : "失败"); + external.setInterfaceOwnershipName(Arrays.stream(InterfaceOwnershipEnum.values()) + .filter(interfaceOwnershipEnum -> interfaceOwnershipEnum.getCode().equals(external.getInterfaceOwnership())) + .findFirst() + .map(InterfaceOwnershipEnum::getOwnershipName) + .orElse(UniversalEnum.OTHER.getValue())); + }); + ExcelUtil util = new ExcelUtil<>(ExternalInterfaceMonitoring.class); + resetCellMaxTextLength(); + util.exportExcel(response, list, "外部接口监测数据"); + } + + public List selectExternal(ExternalInterfaceMonitoring externalInterfaceMonitoring) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); if (externalInterfaceMonitoring.getInterfaceOwnership() != null) { lambdaQueryWrapper.eq(ExternalInterfaceMonitoring::getInterfaceOwnership, externalInterfaceMonitoring.getInterfaceOwnership()); @@ -86,9 +116,15 @@ public class ExternalInterfaceMonitoringTask extends BaseController { if (externalInterfaceMonitoring.getInterfaceName() != null) { lambdaQueryWrapper.like(ExternalInterfaceMonitoring::getInterfaceName, externalInterfaceMonitoring.getInterfaceName()); } + if (externalInterfaceMonitoring.getStartTime() != null && externalInterfaceMonitoring.getEndTime() != null) { + lambdaQueryWrapper.between( + ExternalInterfaceMonitoring::getOperationTime, + externalInterfaceMonitoring.getStartTime(), + externalInterfaceMonitoring.getEndTime() + ); + } lambdaQueryWrapper.orderByDesc(ExternalInterfaceMonitoring::getOperationTime); - List list = externalInterfaceMonitoringMapper.selectList(lambdaQueryWrapper); - return getDataTable(list); + return externalInterfaceMonitoringMapper.selectList(lambdaQueryWrapper); } @Scheduled(cron = "0 0/15 * * * ?") @@ -842,4 +878,25 @@ public class ExternalInterfaceMonitoringTask extends BaseController { voiceBroadcastingToken = JSONObject.parseObject(response.body().string()).getString("accessToken"); } } + + /** + * 利用反射,修改单元格最大长度 + */ + public static void resetCellMaxTextLength() { + SpreadsheetVersion excel2007 = SpreadsheetVersion.EXCEL2007; + if (Integer.MAX_VALUE != excel2007.getMaxTextLength()) { + Field field; + try { + // SpreadsheetVersion.EXCEL2007的_maxTextLength变量 + field = excel2007.getClass().getDeclaredField("_maxTextLength"); + // 关闭反射机制的安全检查,可以提高性能 + field.setAccessible(true); + // 重新设置这个变量属性值 + field.set(excel2007, Integer.MAX_VALUE); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } From 18b49aee1cd06cc1bdcd2f981dc26983b11510b9 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 8 Jul 2024 16:07:56 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=94=B6=E8=B4=B9=E7=AB=99=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=88=86=E6=9E=90table=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcTrafficIncidentsController.java | 297 ++++++++++++++++++ .../export/SelectTollStationAnalysis.java | 74 +++++ 2 files changed, 371 insertions(+) create mode 100644 zc-business/src/main/java/com/zc/business/domain/export/SelectTollStationAnalysis.java diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java index bd05e259..88744a8b 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java @@ -6,14 +6,20 @@ import com.zc.business.domain.DcEventListQuery; import com.zc.business.domain.export.*; import com.zc.business.enums.UniversalEnum; import com.zc.business.service.IDcTrafficIncidentsService; +import com.zc.common.core.httpclient.exception.HttpException; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.ibatis.annotations.Param; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -255,6 +261,297 @@ public class DcTrafficIncidentsController { return trafficIncidentsService.selectTollStationAnalysis(searchType,facilityIdList,controlType,startTime,endTime); } + @ApiOperation(value="导出收费站统计分析table",tags = {"ECharts导出"}) + @GetMapping("/exportSelectTollStationAnalysis") + public void exportSelectTollStationAnalysis(HttpServletResponse response, + @ApiParam(value="查询条件(1:站点,2:原因)", name="searchType", required=true) @RequestParam ("searchType") String searchType, + @ApiParam(value="站点id", name="facilityId", required=false) @RequestParam (name="facilityId",required = false) String[] facilityIdList, + @ApiParam(value="类型(1:封闭,2:限行)", name="controlType", required=false) @RequestParam (name="controlType",required = false) String controlType, + @ApiParam(value="开始时间", name="startTime", required=true) @RequestParam ("startTime") String startTime, + @ApiParam(value="结束时间", name="endTime", required=true) @RequestParam ("endTime") String endTime) throws IOException, HttpException { + AjaxResult ajaxResult = trafficIncidentsService.selectTollStationAnalysis(searchType,facilityIdList,controlType,startTime,endTime); + if ("1".equals(searchType)){ + List list = new ArrayList<>(); + if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { + List> data = (List>) ajaxResult.get("data"); + + Integer closeTotal = 0; + Integer restrictionTotal = 0; + Integer total = 0; + for (Map datum : data) { + SelectTollStationAnalysis selectTollStationAnalysis = new SelectTollStationAnalysis(); + Integer facilityClose = Integer.parseInt(datum.get("facilityClose").toString()); + Integer facilityRestriction = Integer.parseInt(datum.get("facilityRestriction").toString()); + Integer sum = facilityClose + facilityRestriction; + selectTollStationAnalysis.setFacilityName(datum.get("facilityName").toString()); + selectTollStationAnalysis.setFacilityClose(facilityClose.toString()); + selectTollStationAnalysis.setFacilityRestriction(facilityRestriction.toString()); + selectTollStationAnalysis.setSum(sum.toString()); + list.add(selectTollStationAnalysis); + + closeTotal += facilityClose; + restrictionTotal += facilityRestriction; + total += sum; + } + + SelectTollStationAnalysis selectTollStationAnalysis = new SelectTollStationAnalysis(); + selectTollStationAnalysis.setFacilityName("合计"); + selectTollStationAnalysis.setFacilityClose(closeTotal.toString()); + selectTollStationAnalysis.setFacilityRestriction(restrictionTotal.toString()); + selectTollStationAnalysis.setSum(total.toString()); + list.add(selectTollStationAnalysis); + } + + ExcelUtil util = new ExcelUtil<>(SelectTollStationAnalysis.class); + util.exportExcel(response, list, "收费站统计分析列表"); + } else { + XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿 + Sheet sheet = workbook.createSheet(UniversalEnum.THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW.getValue()); // 创建工作表 + + // 创建数据行样式 + CellStyle dataStyle = workbook.createCellStyle(); + dataStyle.setAlignment(HorizontalAlignment.CENTER); + dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); + dataStyle.setBorderRight(BorderStyle.THIN); + dataStyle.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + dataStyle.setBorderLeft(BorderStyle.THIN); + dataStyle.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + dataStyle.setBorderTop(BorderStyle.THIN); + dataStyle.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + dataStyle.setBorderBottom(BorderStyle.THIN); + dataStyle.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + Font dataFont = workbook.createFont(); + dataFont.setFontName(UniversalEnum.ARIAL.getValue()); + dataFont.setFontHeightInPoints((short) UniversalEnum.TEN.getNumber()); + dataStyle.setFont(dataFont); + + // 创建表头样式 + CellStyle headerStyle = workbook.createCellStyle(); + headerStyle.cloneStyleFrom(dataStyle); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); + headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle.setBorderRight(BorderStyle.THIN); + headerStyle.setRightBorderColor(IndexedColors.WHITE.getIndex()); + headerStyle.setBorderLeft(BorderStyle.THIN); + headerStyle.setLeftBorderColor(IndexedColors.WHITE.getIndex()); + headerStyle.setBorderTop(BorderStyle.THIN); + headerStyle.setTopBorderColor(IndexedColors.WHITE.getIndex()); + headerStyle.setBorderBottom(BorderStyle.THIN); + headerStyle.setBottomBorderColor(IndexedColors.WHITE.getIndex()); + + Font headerFont = workbook.createFont(); + headerFont.setFontName(UniversalEnum.ARIAL.getValue()); + headerFont.setFontHeightInPoints((short) UniversalEnum.TEN.getNumber()); + headerFont.setBold(true); + headerFont.setColor(IndexedColors.WHITE.getIndex()); + headerStyle.setFont(headerFont); + + // 添加第一层级表头 + Row row = sheet.createRow(UniversalEnum.ZERO.getNumber()); + String[] row1 = new String[]{}; + if ("2".equals(controlType)){ + row1 = new String[]{"限行原因","","限行站次","","","","","限行时长","","","",""}; + } else { + row1 = new String[]{"封闭原因","","封闭站次","","","","","封闭时长","","","",""}; + } + for (int i = 0; i < row1.length; i++) { + Cell cell = row.createCell(i); + cell.setCellValue(row1[i]); + cell.setCellStyle(headerStyle); + } + + // 添加第二层级表头(与第一层级对齐) + String[] row2 = new String[]{"","","目标时段","","去年同期时段","","同比(%)","目标时段","","去年同期时段","","同比(%)"}; + Row subHeaderRow1 = sheet.createRow(UniversalEnum.ONE.getNumber()); + for (int i = 0; i < row2.length; i++) { + Cell cell = subHeaderRow1.createCell(i); + cell.setCellValue(row2[i]); + cell.setCellStyle(headerStyle); + } + + // 添加第三层级表头 + String[] row3 = new String[]{"","","站次","占比(%)","站次","占比(%)","","站次","占比(%)","站次","占比(%)",""}; + Row subHeaderRow2 = sheet.createRow(UniversalEnum.TWO.getNumber()); + for (int i = 0; i < row3.length; i++) { + Cell cell = subHeaderRow2.createCell(i); + cell.setCellValue(row3[i]); + cell.setCellStyle(headerStyle); + } + + //合并表头单元格,参数依次为起始行,结束行,起始列,结束列 (从0开始) + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.TWO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.TWO.getNumber(), UniversalEnum.SIX.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.SEVEN.getNumber(), UniversalEnum.ELEVEN.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ONE.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.TWO.getNumber(), UniversalEnum.THREE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ONE.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.FOUR.getNumber(), UniversalEnum.FIVE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ONE.getNumber(), UniversalEnum.TWO.getNumber(), UniversalEnum.SIX.getNumber(), UniversalEnum.SIX.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ONE.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.SEVEN.getNumber(), UniversalEnum.EIGHT.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ONE.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.NINE.getNumber(), UniversalEnum.TEN.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ONE.getNumber(), UniversalEnum.TWO.getNumber(), UniversalEnum.ELEVEN.getNumber(), UniversalEnum.ELEVEN.getNumber())); + + + + if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { + List> data = (List>) ajaxResult.get("data"); + //行号 + int rowIndex = 3; + //先塞入恶劣天气类型数据 + for (int i = 2; i < 9; i++) { + Map map = data.get(i); + Row subHeaderRow = sheet.createRow(rowIndex); + Cell cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue(map.get("controlCauseName").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue(map.get("causeTypeName").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber()); + cell.setCellValue(map.get("num").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); + cell.setCellValue(map.get("numRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.FOUR.getNumber()); + cell.setCellValue(map.get("lastYearNum").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.FIVE.getNumber()); + cell.setCellValue(map.get("lastYearNumRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.SIX.getNumber()); + cell.setCellValue(map.get("yearNumRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.SEVEN.getNumber()); + cell.setCellValue(map.get("minuteTime").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.EIGHT.getNumber()); + cell.setCellValue(map.get("timeRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.NINE.getNumber()); + cell.setCellValue(map.get("lastYearTime").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.TEN.getNumber()); + cell.setCellValue(map.get("lastYearTimeRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ELEVEN.getNumber()); + cell.setCellValue(map.get("yearTimeRatio").toString()); + cell.setCellStyle(dataStyle); + + rowIndex++; + } + //再塞入车流量大、交通事故 + for (int i = 0; i < 2; i++) { + Map map = data.get(i); + Row subHeaderRow = sheet.createRow(rowIndex); + Cell cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue(map.get("controlCauseName").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue(map.get("causeTypeName").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber()); + cell.setCellValue(map.get("num").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); + cell.setCellValue(map.get("numRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.FOUR.getNumber()); + cell.setCellValue(map.get("lastYearNum").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.FIVE.getNumber()); + cell.setCellValue(map.get("lastYearNumRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.SIX.getNumber()); + cell.setCellValue(map.get("yearNumRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.SEVEN.getNumber()); + cell.setCellValue(map.get("minuteTime").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.EIGHT.getNumber()); + cell.setCellValue(map.get("timeRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.NINE.getNumber()); + cell.setCellValue(map.get("lastYearTime").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.TEN.getNumber()); + cell.setCellValue(map.get("lastYearTimeRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ELEVEN.getNumber()); + cell.setCellValue(map.get("yearTimeRatio").toString()); + cell.setCellStyle(dataStyle); + + rowIndex++; + } + //最后塞入施工、警备任务、其他 + for (int i = 9; i < 12; i++) { + Map map = data.get(i); + Row subHeaderRow = sheet.createRow(rowIndex); + Cell cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue(map.get("controlCauseName").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue(map.get("causeTypeName").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber()); + cell.setCellValue(map.get("num").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); + cell.setCellValue(map.get("numRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.FOUR.getNumber()); + cell.setCellValue(map.get("lastYearNum").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.FIVE.getNumber()); + cell.setCellValue(map.get("lastYearNumRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.SIX.getNumber()); + cell.setCellValue(map.get("yearNumRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.SEVEN.getNumber()); + cell.setCellValue(map.get("minuteTime").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.EIGHT.getNumber()); + cell.setCellValue(map.get("timeRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.NINE.getNumber()); + cell.setCellValue(map.get("lastYearTime").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.TEN.getNumber()); + cell.setCellValue(map.get("lastYearTimeRatio").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ELEVEN.getNumber()); + cell.setCellValue(map.get("yearTimeRatio").toString()); + cell.setCellStyle(dataStyle); + + rowIndex++; + } + + //合并数据单元格,参数依次为起始行,结束行,起始列,结束列 (从0开始) + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.THREE.getNumber(), UniversalEnum.NINE.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.TEN.getNumber(), UniversalEnum.TEN.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ELEVEN.getNumber(), UniversalEnum.ELEVEN.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.TWELVE.getNumber(), UniversalEnum.TWELVE.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.THIRTEEN.getNumber(), UniversalEnum.THIRTEEN.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber())); + sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.FOURTEEN.getNumber(), UniversalEnum.FOURTEEN.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber())); + + } + + + response.setContentType(UniversalEnum.DERIVE_THE_TWO_WAY_REAL_TIME_TRAFFIC_FLOW_OF_THE_WHOLE_SECTION.getValue()); + response.setCharacterEncoding(UniversalEnum.LOWERCASE_UTF_8.getValue()); + String fileName = "收费站统计分析列表.xlsx"; + response.setHeader("Content-Disposition", "attachment; filename=" + fileName); + // 写入文件 + try (ServletOutputStream outputStream = response.getOutputStream()){ + workbook.write(outputStream); + } finally { + workbook.close(); + } + } + + } + /** * @Description 路网管控-事件管控分析-收费站统计分析echarts(当月) * diff --git a/zc-business/src/main/java/com/zc/business/domain/export/SelectTollStationAnalysis.java b/zc-business/src/main/java/com/zc/business/domain/export/SelectTollStationAnalysis.java new file mode 100644 index 00000000..2d78cea1 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/export/SelectTollStationAnalysis.java @@ -0,0 +1,74 @@ +package com.zc.business.domain.export; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 导出收费站统计分析table对象 + * + * @author ruoyi + * @date 2024-01-13 + */ +public class SelectTollStationAnalysis extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + /** 收费站名称 */ + @Excel(name = "收费站名称") + private String facilityName; + + /** 封闭 */ + @Excel(name = "封闭") + private String facilityClose; + /** 限行 */ + @Excel(name = "限行") + private String facilityRestriction; + /** 合计 */ + @Excel(name = "合计") + private String sum; + + public String getFacilityName() { + return facilityName; + } + + public void setFacilityName(String facilityName) { + this.facilityName = facilityName; + } + + public String getFacilityClose() { + return facilityClose; + } + + public void setFacilityClose(String facilityClose) { + this.facilityClose = facilityClose; + } + + public String getFacilityRestriction() { + return facilityRestriction; + } + + public void setFacilityRestriction(String facilityRestriction) { + this.facilityRestriction = facilityRestriction; + } + + public String getSum() { + return sum; + } + + public void setSum(String sum) { + this.sum = sum; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("facilityName", facilityName) + .append("facilityClose", facilityClose) + .append("facilityRestriction", facilityRestriction) + .append("sum", sum) + .toString(); + } +} From 15cfa9594a9a5787a9903dcaf8d5044601eed25a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Mon, 8 Jul 2024 16:58:17 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=B0=94=E8=B1=A1=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=99=A8=E4=BA=8B=E4=BB=B6=20=E5=8A=A0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/handler/DeviceMessageHandler.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java index 48954624..2a6b446b 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java +++ b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java @@ -611,16 +611,14 @@ public class DeviceMessageHandler { String content = direction + stakeMark + precipitationType; Map contentMap = new HashMap<>(); - contentMap.put("content", content); - contentMap.put("event", meteorologicalDetectorData); - WebSocketService.broadcast(WebSocketEvent.WARNING, contentMap); + JSONObject object = new JSONObject(); object.put("meteorologicalDetectorData", meteorologicalDetectorData); String string = object.toString(); DcWarning dcWarning = new DcWarning(); dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); - dcWarning.setRemark(content); + dcWarning.setRemark(new Date()+" "+content); dcWarning.setWarningTime(new Date()); dcWarning.setWarningType(UniversalEnum.EIGHT_ONE.getNumber()); dcWarning.setWarningSubclass(UniversalEnum.EIGHT_ONE.getValue()); @@ -635,6 +633,10 @@ public class DeviceMessageHandler { if (direction.equals(UniversalEnum.DIRECTION_OF_JINAN.getValue())) { dcWarning.setDirection(UniversalEnum.THREE.getValue()); } + contentMap.put("content", content); + contentMap.put("event", dcWarning); + + WebSocketService.broadcast(WebSocketEvent.WARNING, contentMap); dcWarningService.insertDcWarning(dcWarning); @@ -663,7 +665,7 @@ public class DeviceMessageHandler { String string = object.toString(); DcWarning dcWarning = new DcWarning(); dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); - dcWarning.setRemark(content); + dcWarning.setRemark(new Date()+" "+content); dcWarning.setWarningTime(new Date()); dcWarning.setWarningType(UniversalEnum.EIGHT_FOUR.getNumber()); dcWarning.setWarningSubclass(UniversalEnum.EIGHT_FOUR.getValue()); @@ -677,7 +679,11 @@ public class DeviceMessageHandler { if (direction.equals(UniversalEnum.DIRECTION_OF_JINAN.getValue())) { dcWarning.setDirection(UniversalEnum.THREE.getValue()); } + dcWarningService.insertDcWarning(dcWarning); + contentMap.put("content", content); + contentMap.put("event", dcWarning); + WebSocketService.broadcast(WebSocketEvent.WARNING, contentMap); //待确认数量 dcEventService.getCountNum(); From 9324e081fcd6461df424fcc66a81f7bb192aac34 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 8 Jul 2024 16:58:48 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=20=E6=9E=9A=E4=B8=BE=E7=B1=BB=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20=E7=AE=A1=E6=8E=A7=E8=AE=B0=E5=BD=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcOperLogController.java | 25 ++++++++++--------- .../controller/WeatherForecastController.java | 20 ++++++--------- .../com/zc/business/enums/UniversalEnum.java | 15 ++++++++--- .../service/impl/DcOperLogServiceImpl.java | 2 +- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java b/zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java index 16195efc..4155c72d 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java @@ -5,6 +5,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.PageUtils; import com.zc.business.domain.DcOperLog; import com.zc.business.service.IDcOperLogService; import io.swagger.annotations.Api; @@ -41,39 +42,39 @@ public class DcOperLogController extends BaseController { } /** - * 分页查询列表 + * 分页查询调用功能记录列表 * * @param dcOperLog 请求参数 * @return 分页查询结果 */ @ApiOperation("分页查询列表") - // @PreAuthorize("@ss.hasPermi('iot:facility:list')") + // @PreAuthorize("@ss.hasPermi('iot:facility:list')") @GetMapping("list") - public TableDataInfo listFacility( DcOperLog dcOperLog,@RequestParam(value = "endTime", required = false)Date endTime,@RequestParam(value = "startTime", required = false)Date startTime) { - return getDataTable(dcOperLogService.pageDcOperLog(dcOperLog,endTime,startTime)); + public TableDataInfo listFacility(DcOperLog dcOperLog, @RequestParam(value = "endTime", required = false) Date endTime, @RequestParam(value = "startTime", required = false) Date startTime) { + return getDataTable(dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime)); } /** - * 无分页查询路网设施列表 + * 无分页查询调用功能记录列表 * * @param dcOperLog 请求参数 * @return 查询结果 */ @ApiOperation("无分页查询列表") - // @PreAuthorize("@ss.hasPermi('iot:facility:query')") + // @PreAuthorize("@ss.hasPermi('iot:facility:query')") @GetMapping("query") - public AjaxResult queryFacility( DcOperLog dcOperLog, @RequestParam(value = "endTime", required = false) Date endTime, @RequestParam(value = "startTime", required = false)Date startTime) { - return AjaxResult.success(dcOperLogService.listDcOperLog(dcOperLog,endTime,startTime)); + public AjaxResult queryFacility(DcOperLog dcOperLog, @RequestParam(value = "endTime", required = false) Date endTime, @RequestParam(value = "startTime", required = false) Date startTime) { + return AjaxResult.success(dcOperLogService.listDcOperLog(dcOperLog, endTime, startTime)); } /** - * 根据id查询路网设施信息 + * 根据id查询调用功能记录信息 * * @param id id * @return 查询结果 */ @ApiOperation("根据id查询信息") - // @PreAuthorize("@ss.hasPermi('iot:facility:query')") + // @PreAuthorize("@ss.hasPermi('iot:facility:query')") @GetMapping("{id}") public AjaxResult getFacility(@PathVariable String id) { return AjaxResult.success(dcOperLogService.getById(id)); @@ -101,7 +102,7 @@ public class DcOperLogController extends BaseController { * @return 修改操作结果 */ @ApiOperation("修改") - // @PreAuthorize("@ss.hasPermi('iot:facility:edit')") + // @PreAuthorize("@ss.hasPermi('iot:facility:edit')") @Log(title = "修改", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult editFacility(@Valid @RequestBody DcOperLog dcOperLog) { @@ -115,7 +116,7 @@ public class DcOperLogController extends BaseController { * @return 删除操作结果 */ @ApiOperation("删除") - // @PreAuthorize("@ss.hasPermi('iot:facility:remove')") + // @PreAuthorize("@ss.hasPermi('iot:facility:remove')") @Log(title = "删除", businessType = BusinessType.DELETE) @DeleteMapping("{ids}") public AjaxResult removeFacility(@PathVariable List ids) { diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index f344d94d..ad47570d 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -238,9 +238,6 @@ public class WeatherForecastController extends BaseController { parameter.put("stakeNum", numStake); - - JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); - try { OkHttp okHttp = new OkHttp(); @@ -249,8 +246,8 @@ public class WeatherForecastController extends BaseController { Response response // 请求响应 = okHttp .headers(new HashMap<>()) - .url(weather.getString("get_weather_info")) // 请求地址 - //.url("http://10.166.133.9:38999/api/weather_service/get_weather_info") // 请求地址 + .url(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION.getValue()) // 请求地址 + //.url("http://10.166.133.9:38999/api/weather_service/get_weather_info_jh") // 请求地址 .data(requestParams) .post(); // 请求方法 @@ -403,11 +400,11 @@ public class WeatherForecastController extends BaseController { jsonArray.add(i,jsonObject); }; if (jsonArray.size() != UniversalEnum.ZERO.getNumber()) { - redisCache.deleteObject("currentWeatherAndForecastInformation" + numStake); - redisCache.setCacheObject("currentWeatherAndForecastInformation" + numStake, jsonArray); + redisCache.deleteObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake); + redisCache.setCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake, jsonArray); return AjaxResult.success(jsonArray); } else { - JSONArray cacheObject = redisCache.getCacheObject("currentWeatherAndForecastInformation" + numStake); + JSONArray cacheObject = redisCache.getCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake); return AjaxResult.success(cacheObject); } } else { @@ -448,9 +445,6 @@ public class WeatherForecastController extends BaseController { @PostMapping(value = "/currentWeatherWarningInformationQuery") public AjaxResult currentWeatherWarningInformationQuery(@RequestBody HashMap parameter) { - - JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); - try { OkHttp okHttp = new OkHttp(); @@ -459,8 +453,8 @@ public class WeatherForecastController extends BaseController { Response response // 请求响应 = okHttp .headers(new HashMap<>()) - .url(weather.getString("get_earlyworning_info")) // 请求地址 - //.url("http://10.166.133.9:38999/api/weather_service/get_earlyworning_info") // 请求地址 + .url(UniversalEnum.CURRENT_WEATHER_WARNING_INFORMATION_QUERY.getValue()) // 请求地址 + //.url("http://10.166.133.9:38999/api/weather_service/get_earlyworning_info_jh") // 请求地址 .data(requestParams) .post(); // 请求方法 diff --git a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java index 5282ab65..bf575f57 100644 --- a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java +++ b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java @@ -1,7 +1,7 @@ package com.zc.business.enums; /** - * 情报板车道图标枚举 + * 枚举 * * @author */ @@ -1741,8 +1741,8 @@ public enum UniversalEnum { // 设置预置位 :9021/preset/addPreset SET_PRESET_BIT(0, ":9021/preset/addPreset"), - // currentWeatherAndForecastInformation - CURRENT_WEATHER_AND_FORECAST_INFORMATION(0, "currentWeatherAndForecastInformation"), + // 当前气象及预报信息查询 currentWeatherAndForecastInformation + CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD(0, "currentWeatherAndForecastInformation"), // /preset/addPreset NEW_PRESET_BIT(0, "/preset/addPreset"), @@ -1759,6 +1759,12 @@ public enum UniversalEnum { // application/vnd.openxmlformats-officedocument.spreadsheetml.sheet DERIVE_THE_TWO_WAY_REAL_TIME_TRAFFIC_FLOW_OF_THE_WHOLE_SECTION(0, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), + // 当前气象预警信息查询 http://10.166.133.9:38999/api/weather_service/get_earlyworning_info_jh + CURRENT_WEATHER_WARNING_INFORMATION_QUERY(0, "http://10.166.133.9:38999/api/weather_service/get_earlyworning_info_jh"), + + // 当前气象及预报信息查询 http://10.166.133.9:38999/api/weather_service/get_weather_info_jh + CURRENT_WEATHER_AND_FORECAST_INFORMATION(0, "http://10.166.133.9:38999/api/weather_service/get_weather_info_jh"), + // dc_device_type DC_DEVICE_TYPE(0, "dc_device_type"), @@ -2151,6 +2157,9 @@ public enum UniversalEnum { // 右小括号 CLOSING_PARENTHESIS(0, ")"), + // 杠杠左中括号 + BARRE_LEFT_CENTER_BRACKET(0, "\\["), + // 左中括号 LEFT_CENTER_BRACKET(0, "["), diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java index 4c0e3e1d..97c523f6 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java @@ -68,7 +68,7 @@ public class DcOperLogServiceImpl extends ServiceImpl Date: Mon, 8 Jul 2024 17:24:21 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=94=B6=E8=B4=B9?= =?UTF-8?q?=E7=AB=99=E7=BB=9F=E8=AE=A1=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/service/impl/DcTrafficStatisticsServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java index 266475e9..78b64813 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java @@ -711,12 +711,11 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi if (JSON.isValidArray(jsonString)) { JSONArray jsonArray = JSON.parseArray(jsonString); Map sumByName = new LinkedHashMap<>(); - Integer totalFlow1 = 0; + List> list = new ArrayList(); for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object JSONObject jsonObject = (JSONObject) item; - totalFlow1 = totalFlow1 + jsonObject.getInteger("total_flow"); // 获取当前时间 LocalTime now = LocalTime.now(); @@ -729,7 +728,6 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi sumByName.put(name, totalFlow); } } - System.out.println("总数===:" + totalFlow1); // 正确创建新的映射对象并添加到list中 for (Map.Entry entry : sumByName.entrySet()) { Map singleResult = new LinkedHashMap<>(); // 每次循环都创建一个新的映射