diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java index f1d1e1aa..5deafaf7 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java @@ -151,7 +151,11 @@ public class DcDeviceOnlineController extends BaseController { for (String type : types) { Map map = new HashMap<>(); List listOfType = stringListMap.getOrDefault(type, new ArrayList<>()); + Map> localDateListMap = listOfType.stream() + .collect(Collectors.groupingBy(onlineSum -> onlineSum.getStatisticalDate().toLocalDate())); +/* Map> localDateListMap = listOfType.stream().collect(Collectors.groupingBy(OnlineSum::getStatisticalDate)); +*/ for (LocalDate date = start.toLocalDate(); date.isBefore(end.toLocalDate().plusDays(1)); date = date.plusDays(1)) { List dayList = localDateListMap.getOrDefault(date, new ArrayList<>()); map.put(date.toString(), MathUtil.doubleTwoDecimalStr(dayList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0)) + "%"); @@ -191,7 +195,8 @@ public class DcDeviceOnlineController extends BaseController { List listOfType = stringListMap.getOrDefault(type, new ArrayList<>()); // 按日期分组 - Map> localDateListMap = listOfType.stream().collect(Collectors.groupingBy(OnlineSum::getStatisticalDate)); + Map> localDateListMap = listOfType.stream() .collect(Collectors.groupingBy(onlineSum -> onlineSum.getStatisticalDate().toLocalDate())); + // 按日期统计 for (LocalDate date = start.toLocalDate(); date.isBefore(end.toLocalDate().plusDays(1)); date = date.plusDays(1)) { @@ -203,7 +208,7 @@ public class DcDeviceOnlineController extends BaseController { LocalDateTime startHour = LocalDateTime.of(date, LocalTime.of(hour, 0)); LocalDateTime endHour = startHour.plusHours(1); List hourList = dayList.stream() - .filter(os -> os.getStatisticalDate().isAfter(ChronoLocalDate.from(startHour)) && os.getStatisticalDate().isBefore(ChronoLocalDate.from(endHour))) + .filter(os -> os.getStatisticalDate().toLocalDate().isAfter(ChronoLocalDate.from(startHour)) && os.getStatisticalDate().toLocalDate().isBefore(ChronoLocalDate.from(endHour))) .collect(Collectors.toList()); double averageRate = hourList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0); @@ -315,8 +320,8 @@ public class DcDeviceOnlineController extends BaseController { itemMap.put(SUCESS_RATE, formatPercentage(onlineRate*100));//在线率 itemMap.put(FAIL_RATE, formatPercentage(offlineRate*100));//离线率 // 累加总的在线和离线设备数量 -/* totalOnline.addAndGet(onlineCount); - totalOffline.addAndGet(offlineCount);*/ + totalOnline.addAndGet(onlineCount); + totalOffline.addAndGet(offlineCount); returnMap.put(v, itemMap); }); Map allMap = new HashMap<>(); @@ -333,8 +338,8 @@ public class DcDeviceOnlineController extends BaseController { Map totalOfflineMap = Collections.unmodifiableMap(new HashMap() {{ put(FAIL_RATE, totalOffline.get()); }}); - allMap.put(SUCESS_RATE, formatPercentage((totalOnlineMap.get(SUCESS_RATE)/useDeviceList.size())*100) ); - allMap.put(FAIL_RATE,formatPercentage((totalOfflineMap.get(FAIL_RATE)/useDeviceList.size())*100)); + allMap.put(SUCESS_RATE, formatPercentage(((double)totalOnlineMap.get(SUCESS_RATE)/useDeviceList.size())*100) ); + allMap.put(FAIL_RATE,formatPercentage(((double)totalOfflineMap.get(FAIL_RATE)/useDeviceList.size())*100)); returnMap.put(All_TYPE, allMap); Map sortMap = new TreeMap<>(); String orderRule = redisCache.getCacheObject(ORDERRULE); diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java index ed5a33c1..3e28caec 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java @@ -303,6 +303,27 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } + /** + * 车流量异常事件流量查询 + * @param eventId 事件id + */ + @ApiOperation("车流量异常事件流量查询") + @GetMapping("/history/eventtrafficflowcnt") + public AjaxResult eventtrafficflowcnt(String eventId ) throws HttpException { + JSONArray mapList = dcTrafficStatisticsService.eventtrafficflowcnt(eventId); + // 将查询结果封装为成功响应并返回 + return AjaxResult.success(mapList); + } + /** + * 交通流统计分析重点数据查询交通流异常信息 + */ + @ApiOperation("交通流统计分析重点数据查询交通流异常信息") + @GetMapping("/history/exampleQueryTrafficFlowAnomalies") + public AjaxResult exampleQueryTrafficFlowAnomalies(String startTime,String endTime ) throws HttpException { + JSONArray mapList = dcTrafficStatisticsService.exampleQueryTrafficFlowAnomalies(startTime,endTime); + // 将查询结果封装为成功响应并返回 + return AjaxResult.success(mapList); + } /** * 导出车流量时段分析 diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java new file mode 100644 index 00000000..d899bb6b --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java @@ -0,0 +1,263 @@ +package com.zc.business.controller; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.zc.business.domain.DcDevice; +import com.zc.business.enums.UniversalEnum; +import com.zc.common.core.httpclient.exception.HttpException; +import io.swagger.v3.oas.annotations.Parameter; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.zc.business.domain.DcTrafficSurveyData; +import com.zc.business.service.IDcTrafficSurveyDataService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 一类交调数据Controller + * + * @author liuwenge + * @date 2024-10-29 + */ +@RestController +@RequestMapping("/trafficSurveyData/dcTrafficSurveyData") +public class DcTrafficSurveyDataController extends BaseController +{ + @Autowired + private IDcTrafficSurveyDataService dcTrafficSurveyDataService; + + @Resource + private DcDeviceController dcDeviceController; + + @Scheduled(cron = "0 5 * * * ?") + public void syncTrafficSectionData() throws HttpException, IOException { + + HashMap props = new HashMap<>(); + // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内 + props.put("terms[0].column", "timestamp$BTW"); + ArrayList dateList = new ArrayList<>(); + // 添加当前前一小时的开始和结束时间到列表,用于设定时间范围 + Date now = new Date(); + // 计算上一个小时的时间 + Date lastHourStart = DateUtil.beginOfHour(DateUtil.offsetHour(now, -1)); + Date lastHourEnd = DateUtil.endOfHour(DateUtil.offsetHour(now, -1)); + // 将上一个小时的开始和结束时间添加到列表 + dateList.add(DateUtil.format(lastHourStart, "yyyy-MM-dd HH:mm:ss")); + dateList.add(DateUtil.format(lastHourEnd, "yyyy-MM-dd HH:mm:ss")); + // 将日期列表以逗号分隔并设置为查询条件的值 + props.put("terms[0].value", String.join(UniversalEnum.COMMA.getValue(), dateList)); + props.put("paging", false); + props.put("sorts[0].order", "asc"); + props.put("sorts[0].name", "timestamp"); + + + List deviceList = dcTrafficSurveyDataService.selectDeviceList(); + String propertyId = "01"; //功能码 + + List batchData = new ArrayList<>(); + for (DcDevice dcDevice : deviceList) { + + Object data = JSON.parseObject(dcDeviceController.queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props).get("data").toString()).get("data"); + JSONArray dataArray = JSON.parseArray(data.toString()); + + Integer hezeTotal = 0; + Integer jinanTotal = 0; + for (Object o : dataArray) { + JSONObject jsonObject = JSON.parseObject(o.toString()); + JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString()); + hezeTotal += Integer.parseInt(formatValue.get("1").toString()); + jinanTotal += Integer.parseInt(formatValue.get("3").toString()); + } + + //菏泽方向数据 + DcTrafficSurveyData hezeData = new DcTrafficSurveyData(); + hezeData.setIotDeviceId(dcDevice.getIotDeviceId()); + hezeData.setStakeMark(dcDevice.getStakeMark()); + hezeData.setDirection("1"); + hezeData.setTimestamp(lastHourStart); + hezeData.setTrafficVolume(Long.valueOf(hezeTotal)); + batchData.add(hezeData); + //济南方向数据 + DcTrafficSurveyData jinanData = new DcTrafficSurveyData(); + jinanData.setIotDeviceId(dcDevice.getIotDeviceId()); + jinanData.setStakeMark(dcDevice.getStakeMark()); + jinanData.setDirection("3"); + jinanData.setTimestamp(lastHourStart); + jinanData.setTrafficVolume(Long.valueOf(jinanTotal)); + batchData.add(jinanData); + + } + + dcTrafficSurveyDataService.batchInsert(batchData); + + } + + /** + * 查询一类交调数据列表 + */ + @GetMapping("/list") + public AjaxResult list(DcTrafficSurveyData dcTrafficSurveyData) + { + return dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); + } + + /** + * 导出一类交调数据列表 + */ + @Log(title = "一类交调数据", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, DcTrafficSurveyData dcTrafficSurveyData) throws IOException { + AjaxResult ajaxResult = dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); + if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { + Map data = (Map) ajaxResult.get("data"); + List> columnList = (List>) data.get("columnList"); + List> rowList = (List>) data.get("rowList"); + + XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿 + Sheet sheet = workbook.createSheet("一类交调站"); // 创建工作表 + + // 创建数据行样式 + 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); + 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()); + Cell cell = row.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue("设备名称"); + cell.setCellStyle(headerStyle); + cell = row.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue("方向"); + cell.setCellStyle(headerStyle); + int i; + for (i = 0; i < columnList.size(); i++) { + cell = row.createCell(i + 2); + cell.setCellValue(columnList.get(i).get("label").toString()); + cell.setCellStyle(headerStyle);; + } + cell = row.createCell(i + 2); + cell.setCellValue("合计"); + cell.setCellStyle(headerStyle); + + + for (int j = 0; j < rowList.size(); j++) { + Row subHeaderRow = sheet.createRow(j+1); + cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue("一类交调站"+rowList.get(j).get("stakeMark").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue(rowList.get(j).get("direction").toString().equals("1") ? "济南方向" : "菏泽方向"); + cell.setCellStyle(dataStyle); + int k = 0; + for (k = 0; k < columnList.size(); k++) { + cell = subHeaderRow.createCell(k + 2); + cell.setCellValue(rowList.get(j).get(columnList.get(k).get("key")).toString()); + cell.setCellStyle(dataStyle);; + } + cell = subHeaderRow.createCell(k+2); + cell.setCellValue(rowList.get(j).get("total").toString()); + cell.setCellStyle(dataStyle); + } + + + // 写入文件 + try (ServletOutputStream outputStream = response.getOutputStream()){ + workbook.write(outputStream); + } finally { + workbook.close(); + } + + } + } + + /** + * 获取一类交调数据详细信息 + */ + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(dcTrafficSurveyDataService.selectDcTrafficSurveyDataById(id)); + } + + /** + * 新增一类交调数据 + */ + @Log(title = "一类交调数据", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DcTrafficSurveyData dcTrafficSurveyData) + { + return toAjax(dcTrafficSurveyDataService.insertDcTrafficSurveyData(dcTrafficSurveyData)); + } + + /** + * 修改一类交调数据 + */ + @Log(title = "一类交调数据", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DcTrafficSurveyData dcTrafficSurveyData) + { + return toAjax(dcTrafficSurveyDataService.updateDcTrafficSurveyData(dcTrafficSurveyData)); + } + + /** + * 删除一类交调数据 + */ + @Log(title = "一类交调数据", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(dcTrafficSurveyDataService.deleteDcTrafficSurveyDataByIds(ids)); + } +} diff --git a/zc-business/src/main/java/com/zc/business/controller/SideSlopeController.java b/zc-business/src/main/java/com/zc/business/controller/SideSlopeController.java index 2b0b5697..367a4cb2 100644 --- a/zc-business/src/main/java/com/zc/business/controller/SideSlopeController.java +++ b/zc-business/src/main/java/com/zc/business/controller/SideSlopeController.java @@ -2,28 +2,44 @@ package com.zc.business.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.service.ISysConfigService; import com.zc.business.domain.DcWarning; import com.zc.business.enums.UniversalEnum; import com.zc.business.service.IDcWarningService; +import com.zc.common.core.httpclient.OkHttp; +import com.zc.common.core.httpclient.exception.HttpException; +import com.zc.common.core.httpclient.request.RequestParams; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import okhttp3.*; import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import org.springframework.beans.factory.annotation.Autowired; 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.PostConstruct; import javax.annotation.Resource; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; -import java.util.Date; +import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.zip.GZIPInputStream; /** @@ -38,7 +54,9 @@ import java.util.concurrent.TimeUnit; @Component @RequestMapping("/sideSlope") public class SideSlopeController extends BaseController { - + @Resource + private RedisCache redisCache; + public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); @Resource private IDcWarningService dcWarningService; @Autowired @@ -47,6 +65,156 @@ public class SideSlopeController extends BaseController { private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + @ApiOperation("获取token") + @PostMapping("/authenticate") + public JSONObject authenticate() throws IOException { + OkHttpClient client = new OkHttpClient(); + + // 构造请求体 + Map map = new LinkedHashMap<>(); + map.put("UserNameOrEmailAddress", configService.selectConfigByKey("UserNameOrEmailAddress"));//用户名 + map.put("Password", configService.selectConfigByKey("Password"));//登录密码 + ObjectMapper objectMapper = new ObjectMapper(); + String jsonInput = objectMapper.writeValueAsString(map); + RequestBody requestBody = RequestBody.create(JSON, jsonInput); + + // 创建请求 + Request request = new Request.Builder() + .url(configService.selectConfigByKey("accessTokenApi")) + .post(requestBody) + .build(); + + // 发送请求并处理响应 + try (Response response = client.newCall(request).execute()) { + if (!response.isSuccessful()) { + throw new IOException("Unexpected code " + response); + } + // 正确解析响应体中的JSON数据 + String responseBody = response.body().string(); + JSONObject jsonResult = JSONObject.parseObject(responseBody); + return jsonResult; + } + } + + /** + * 获取测点列表 + * @return + * @throws IOException + * @throws HttpException + */ + @ApiOperation("获取边坡测点列表") + + @GetMapping("/GetMeasurePointList") + public AjaxResult GetMeasurePointList() throws IOException, HttpException { + JSONObject jsonResult = null; + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(); + requestParams.put("proCode", configService.selectConfigByKey("proCode")); + requestParams.put("unitCode", configService.selectConfigByKey("unitCode")); + + Object accessToken = redisCache.getCacheObject("accessToken"); + if (accessToken==null){ + JSONObject authenticate = authenticate(); + accessToken = authenticate.getJSONObject("result").getString("accessToken"); + redisCache.setCacheObject("accessToken",accessToken); + redisCache.expire("accessToken", UniversalEnum.THREE.getNumber() * UniversalEnum.TWENTY_FOUR.getNumber() * UniversalEnum.THREE_THOUSAND_SIX_HUNDRED.getNumber());//设置过期时间s秒 + } + + // http://jsgl.sdgsbim.com:8616/api/RoadMajorPlatform/GetMeasurePointList?proCode=JHGKJ&unitCode=60-01.0002.00.00 + Map header = new HashMap<>(); + header.put("Authorization", "Bearer "+accessToken.toString()); + Response response // 请求响应 + = okHttp + .headers(header) + .url(configService.selectConfigByKey("GetMeasurePointListAPI")) // 请求地址 + .data(requestParams) // 请求参数 + .get(); // 请求方法 + + if (response.body() != null) { + jsonResult = JSONObject.parseObject(response.body().string()); + } + // 正确解析响应体中的JSON数据 + return AjaxResult.success(jsonResult) ; + } + + /** + * 获取长历史数据 + * @return + * @throws IOException + * @throws HttpException + */ + @ApiOperation("获取边坡历史数据") + @GetMapping("/GetPointDataListAsync") + public AjaxResult GetPointDataListAsync( + @ApiParam(value = "测点编号", name = "meaPointNum", required = true) String meaPointNum, + @ApiParam(value = "开始时间(时间戳)", name = "starttime", required = true) long starttime, + @ApiParam(value = "结束时间(时间戳)", name = "endtime", required = true) long endtime + + ) throws IOException, HttpException { + + JSONObject jsonResult = null; + JSONArray jsonArray = null; + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(); + requestParams.put("projCode",configService.selectConfigByKey("proCode"));//项目编号 如 JHGKJ + requestParams.put("unitCode", configService.selectConfigByKey("unitCode"));//项目单位工程编号 如 60-01.0002.00.00 + requestParams.put("meaPointNum", meaPointNum);//测点编号如 PR-YLJ01-067441-05/05 + requestParams.put("starttime", starttime);//开始时间如 1713369599000 + requestParams.put("endtime", endtime);//结束时间 如 1713887999000 + + Object accessToken = redisCache.getCacheObject("accessToken"); + if (accessToken==null){ + System.out.println("null+++++++++++++++++++++++"); + JSONObject authenticate = authenticate(); + accessToken = authenticate.getJSONObject("result").getString("accessToken"); + redisCache.setCacheObject("accessToken",accessToken); + redisCache.expire("accessToken", UniversalEnum.THREE.getNumber() * UniversalEnum.TWENTY_FOUR.getNumber() * UniversalEnum.THREE_THOUSAND_SIX_HUNDRED.getNumber());//设置过期时间s秒 + } + + // http://jsgl.sdgsbim.com:8616/api/RoadMajorPlatform/GetMeasurePointList?proCode=JHGKJ&unitCode=60-01.0002.00.00 + Map header = new HashMap<>(); + header.put("Authorization", "Bearer "+accessToken.toString()); + Response response // 请求响应 + = okHttp + .headers(header) + .url(configService.selectConfigByKey("GetPointDataListAsyncAPI")) // 请求地址 + .data(requestParams) // 请求参数 + .get(); // 请求方法 + + if (response.body() != null) { + jsonResult = JSONObject.parseObject(response.body().string()); + String jsonObjec =jsonResult.getString("result").replace("\r\n", UniversalEnum.EMPTY_STRING.getValue()); + jsonArray = extracted(jsonObjec); + } + // 正确解析响应体中的JSON数据 + return AjaxResult.success(jsonArray); + } + /** + * Base64解码 + */ + private JSONArray extracted(String base64EncodedCompressedData) throws IOException { + // Base64解码 + byte[] compressedData = Base64.getDecoder().decode(base64EncodedCompressedData); + StringBuilder output = new StringBuilder(); + // 解压缩 + try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(compressedData); + GZIPInputStream gzipInputStream = new GZIPInputStream(byteArrayInputStream); + InputStreamReader inputStreamReader = new InputStreamReader(gzipInputStream, StandardCharsets.UTF_8); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { + + String line; + while ((line = bufferedReader.readLine()) != null) { + output.append(line); + } + } + // 将StringBuilder转换为字符串 + String jsonString = output.toString(); +// 将字符串转换为JSONObject + JSONArray jsonObject = JSONArray.parseArray(jsonString); + return jsonObject; + } @PostConstruct private AjaxResult mqttSubscription() throws Exception { diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java new file mode 100644 index 00000000..705dbdb0 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java @@ -0,0 +1,130 @@ +package com.zc.business.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 一类交调数据对象 dc_traffic_survey_data + * + * @author liuwenge + * @date 2024-10-29 + */ +public class DcTrafficSurveyData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 物联设备主键 */ + @Excel(name = "物联设备主键") + private String iotDeviceId; + + /** 所在桩号 */ + @Excel(name = "所在桩号") + private String stakeMark; + + /** 方向1-上行,2-中,3-下行 */ + @Excel(name = "方向1-上行,2-中,3-下行") + private String direction; + + /** 采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date timestamp; + + /** 车流量 */ + @Excel(name = "车流量") + private Long trafficVolume; + + private String type; + + private String times; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setIotDeviceId(String iotDeviceId) + { + this.iotDeviceId = iotDeviceId; + } + + public String getIotDeviceId() + { + return iotDeviceId; + } + public void setStakeMark(String stakeMark) + { + this.stakeMark = stakeMark; + } + + public String getStakeMark() + { + return stakeMark; + } + public void setDirection(String direction) + { + this.direction = direction; + } + + public String getDirection() + { + return direction; + } + public void setTimestamp(Date timestamp) + { + this.timestamp = timestamp; + } + + public Date getTimestamp() + { + return timestamp; + } + public void setTrafficVolume(Long trafficVolume) + { + this.trafficVolume = trafficVolume; + } + + public Long getTrafficVolume() + { + return trafficVolume; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getTimes() { + return times; + } + + public void setTimes(String times) { + this.times = times; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("iotDeviceId", getIotDeviceId()) + .append("stakeMark", getStakeMark()) + .append("direction", getDirection()) + .append("timestamp", getTimestamp()) + .append("trafficVolume", getTrafficVolume()) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java b/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java index af568c98..ed5b2da8 100644 --- a/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java +++ b/zc-business/src/main/java/com/zc/business/domain/OnlineSum.java @@ -39,7 +39,7 @@ public class OnlineSum implements java.io.Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "统计日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") - private LocalDate statisticalDate;//统计日期 + private LocalDateTime statisticalDate;//统计日期 private String deviceType;//设备类型 private int totalCount;//当天总次数 private int sendCount;//发送数据包总数 @@ -134,11 +134,11 @@ public class OnlineSum implements java.io.Serializable { this.networkQuality = networkQuality; } - public LocalDate getStatisticalDate() { + public LocalDateTime getStatisticalDate() { return statisticalDate; } - public void setStatisticalDate(LocalDate statisticalDate) { + public void setStatisticalDate(LocalDateTime statisticalDate) { this.statisticalDate = statisticalDate; } @@ -296,7 +296,7 @@ public class OnlineSum implements java.io.Serializable { this.networkQuality = onlineLog.getNetworkQuality(); if(this.deviceStatus.equals(DcDevice.ONLINE)) this.lastOnlineTime = onlineLog.getMonitorTime(); - this.statisticalDate = onlineLog.getMonitorTime().toLocalDate(); + this.statisticalDate = onlineLog.getMonitorTime(); return this; } 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 032ba26f..e4f1a166 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 @@ -1789,6 +1789,11 @@ RADAR_ASSOCIATED_MONITORING_POINT_QUERY_INTERFACE(0,"/api/radar/v1/selectRelateB // 全路段双向实时车流量 /api/dc/query/gan_jihe_d_vehtypeflow THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW_URL(0, "/api/dc/query/gan_jihe_d_vehtypeflow"), + //车流量异常事件流量查询 + QUERY_TRAFFIC_OF_ABNORMAL_TRAFFIC_EVENTS(0,"/api/dc/query/gan_jihe_d_eventtrafficflowcnt"), + // *交通流统计分析重点数据查询交通流异常信息 + TRAFFIC_FLOW_STATISTICAL_KEY_DATA_QUERY(0,"/api/dc/query/gan_jihe_d_trafficexception"), + // 雷达数据 http://www.nmc.cn/publish/radar/chinaall.html RADAR_DATA(0, "http://www.nmc.cn/publish/radar/chinaall.html"), diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java new file mode 100644 index 00000000..0a94df6b --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java @@ -0,0 +1,71 @@ +package com.zc.business.mapper; + +import java.util.List; + +import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcTrafficSurveyData; + +/** + * 一类交调数据Mapper接口 + * + * @author liuwenge + * @date 2024-10-29 + */ +public interface DcTrafficSurveyDataMapper +{ + /** + * 查询一类交调数据 + * + * @param id 一类交调数据主键 + * @return 一类交调数据 + */ + public DcTrafficSurveyData selectDcTrafficSurveyDataById(Long id); + + /** + * 查询一类交调数据列表 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 一类交调数据集合 + */ + List selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData); + + List selectDay(DcTrafficSurveyData dcTrafficSurveyData); + List selectMonth(DcTrafficSurveyData dcTrafficSurveyData); + List selectYear(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 新增一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int insertDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 修改一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int updateDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 删除一类交调数据 + * + * @param id 一类交调数据主键 + * @return 结果 + */ + int deleteDcTrafficSurveyDataById(Long id); + + /** + * 批量删除一类交调数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteDcTrafficSurveyDataByIds(Long[] ids); + + List selectDeviceList(); + + int batchInsert(List batchData); +} diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java index 32b6fe4a..9a5cb3c7 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java @@ -65,4 +65,10 @@ public interface IDcTrafficStatisticsService { int trafficFlowAtToll(String startDate)throws HttpException, IOException; int yesterdayTrafficFlowAtToll(String startDate)throws HttpException, IOException; + + JSONArray eventtrafficflowcnt(String eventId) throws HttpException; + /** + * 交通流统计分析重点数据查询交通流异常信息 + */ + JSONArray exampleQueryTrafficFlowAnomalies(String startTime, String endTime) throws HttpException; } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java new file mode 100644 index 00000000..78838bbc --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java @@ -0,0 +1,80 @@ +package com.zc.business.service; + +import java.util.List; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcTrafficSurveyData; + +/** + * 一类交调数据Service接口 + * + * @author liuwenge + * @date 2024-10-29 + */ +public interface IDcTrafficSurveyDataService +{ + /** + * 查询一类交调数据 + * + * @param id 一类交调数据主键 + * @return 一类交调数据 + */ + public DcTrafficSurveyData selectDcTrafficSurveyDataById(Long id); + + /** + * 查询一类交调数据列表 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 一类交调数据集合 + */ + AjaxResult selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 新增一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int insertDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 修改一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int updateDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 批量删除一类交调数据 + * + * @param ids 需要删除的一类交调数据主键集合 + * @return 结果 + */ + int deleteDcTrafficSurveyDataByIds(Long[] ids); + + /** + * 删除一类交调数据信息 + * + * @param id 一类交调数据主键 + * @return 结果 + */ + int deleteDcTrafficSurveyDataById(Long id); + + /** + * 查询所有交调设备 + * + * @param + * @return 结果 + */ + List selectDeviceList(); + + /** + * 批量插入 + * + * @param batchData 一类交调数据 + * @return 结果 + */ + int batchInsert(List batchData); +} 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 e0a40fc9..075f19cc 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 @@ -1368,6 +1368,97 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi } + @Override + public JSONArray eventtrafficflowcnt(String eventId) throws HttpException { + + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(); + + requestParams.put("sysid", sysid); + + JSONObject parameters = new JSONObject() { + { + put("event_id", eventId); + } + }; + + requestParams.put("parameters", parameters.toJSONString()); + + Map headers = new HashMap<>(); + headers.put("Authorization", getAccessToken()); + try { + Response response // 请求响应 + = okHttp + .headers(headers) + .url(baseUrl + UniversalEnum.QUERY_TRAFFIC_OF_ABNORMAL_TRAFFIC_EVENTS.getValue()) // 请求地址 + .data(requestParams) // 请求参数 + .post(); // 请求方法 + + ResponseBody body = response.body(); + if (body != null) { + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + } else { + return new JSONArray(); + } + } + return new JSONArray(); + } catch (IOException e) { + // 处理异常 + e.printStackTrace(); + return new JSONArray(); + } + } + /** + * 交通流统计分析重点数据查询交通流异常信息 + */ + @Override + public JSONArray exampleQueryTrafficFlowAnomalies(String startTime, String endTime) throws HttpException { + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(); + + requestParams.put("sysid", sysid); + + JSONObject parameters = new JSONObject() { + { + put("start_time", startTime); + put("end_time", endTime); + } + }; + + requestParams.put("parameters", parameters.toJSONString()); + + Map headers = new HashMap<>(); + headers.put("Authorization", getAccessToken()); + try { + Response response // 请求响应 + = okHttp + .headers(headers) + .url(baseUrl + UniversalEnum.TRAFFIC_FLOW_STATISTICAL_KEY_DATA_QUERY.getValue()) // 请求地址 + .data(requestParams) // 请求参数 + .post(); // 请求方法 + + ResponseBody body = response.body(); + if (body != null) { + String jsonString = body.string(); + if (JSON.isValidArray(jsonString)) { + return JSON.parseArray(jsonString); + } else { + return new JSONArray(); + } + } + return new JSONArray(); + } catch (IOException e) { + // 处理异常 + e.printStackTrace(); + return new JSONArray(); + } + } + + private Response getResponseTrafficFlowAtToll(String startDate, String stationType) throws HttpException, IOException { // 创建OkHttpClient.Builder实例 OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java new file mode 100644 index 00000000..c9a35c5f --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java @@ -0,0 +1,248 @@ +package com.zc.business.service.impl; + +import java.util.*; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcDevice; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zc.business.mapper.DcTrafficSurveyDataMapper; +import com.zc.business.domain.DcTrafficSurveyData; +import com.zc.business.service.IDcTrafficSurveyDataService; + +/** + * 一类交调数据Service业务层处理 + * + * @author liuwenge + * @date 2024-10-29 + */ +@Service +public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataService +{ + @Autowired + private DcTrafficSurveyDataMapper dcTrafficSurveyDataMapper; + + /** + * 查询一类交调数据 + * + * @param id 一类交调数据主键 + * @return 一类交调数据 + */ + @Override + public DcTrafficSurveyData selectDcTrafficSurveyDataById(Long id) + { + return dcTrafficSurveyDataMapper.selectDcTrafficSurveyDataById(id); + } + + /** + * 查询一类交调数据列表 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 一类交调数据 + */ + @Override + public AjaxResult selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) + { + List> rowList = new ArrayList<>(); + List> columnList = getColumnList(dcTrafficSurveyData); + List dataList = new ArrayList<>(); + if (dcTrafficSurveyData.getType().equals("day")){ + dataList = dcTrafficSurveyDataMapper.selectDay(dcTrafficSurveyData); + } else if (dcTrafficSurveyData.getType().equals("month")){ + dataList = dcTrafficSurveyDataMapper.selectMonth(dcTrafficSurveyData); + } else if (dcTrafficSurveyData.getType().equals("year")){ + dataList = dcTrafficSurveyDataMapper.selectYear(dcTrafficSurveyData); + } + Map>>> groupedData = dataList.stream() + .collect(Collectors.groupingBy( + DcTrafficSurveyData::getIotDeviceId, // 第一级分组:按设备Id + Collectors.groupingBy(DcTrafficSurveyData::getDirection, // 第二级分组:按方向 + Collectors.groupingBy(DcTrafficSurveyData::getTimes) // 第三级分组:按时间 + ))); + List deviceList = dcTrafficSurveyDataMapper.selectDeviceList(); + + Map row = new HashMap<>(); + for (DcDevice dcDevice : deviceList) { + if (groupedData.containsKey(dcDevice.getIotDeviceId())){ + + Map>> directionData = groupedData.get(dcDevice.getIotDeviceId()); + //单个设备济南方向数据 + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","1"); + + if (directionData.containsKey("1")){ + Integer total = 0; + //单个设备济南方向分时数据 + Map> directionList = directionData.get("1"); + for (Map columnMap : columnList) { + if (directionList.containsKey(columnMap.get("key"))){ + List timeList = directionList.get(columnMap.get("key")); + row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); + total += timeList.get(0).getTrafficVolume().intValue(); + } else { + row.put(columnMap.get("key"),0); + } + } + row.put("total",total); + } else { + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + row.put("total",0); + } + } + rowList.add(row); + + //单个设备菏泽方向数据 + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","3"); + if (directionData.containsKey("3")){ + Integer total = 0; + //单个设备菏泽方向分时数据 + Map> directionList = directionData.get("3"); + for (Map columnMap : columnList) { + if (directionList.containsKey(columnMap.get("key"))){ + List timeList = directionList.get(columnMap.get("key")); + row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); + total += timeList.get(0).getTrafficVolume().intValue(); + } else { + row.put(columnMap.get("key"),0); + } + } + row.put("total",total); + } else { + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + row.put("total",0); + } + } + rowList.add(row); + } else { + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","1"); + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + } + row.put("total",0); + rowList.add(row); + + row= new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","3"); + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + } + row.put("total",0); + rowList.add(row); + } + } + Map result = new HashMap<>(); + result.put("rowList",rowList); + result.put("columnList",columnList); + return AjaxResult.success(result); + + } + + public List> getColumnList(DcTrafficSurveyData dcTrafficSurveyData){ + List> columnList = new ArrayList<>(); + Map column; + if (dcTrafficSurveyData.getType().equals("day")){ + for (int i = 0; i < 24; i++) { + column = new HashMap<>(); + column.put("label",i+"点"); + column.put("key",String.valueOf(i)); + columnList.add(column); + } + } else if (dcTrafficSurveyData.getType().equals("month")){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dcTrafficSurveyData.getTimestamp()); + int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); // 获取这个月的最大天数 + for (int i = 1; i <= maxDay; i++) { + column = new HashMap<>(); + column.put("label",i+"日"); + column.put("key",String.valueOf(i)); + columnList.add(column); + } + } else if (dcTrafficSurveyData.getType().equals("year")){ + for (int i = 1; i <= 12; i++) { + column = new HashMap<>(); + column.put("label",i+"月"); + column.put("key",String.valueOf(i)); + columnList.add(column); + } + } + return columnList; + } + /** + * 新增一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + @Override + public int insertDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData) + { + return dcTrafficSurveyDataMapper.insertDcTrafficSurveyData(dcTrafficSurveyData); + } + + /** + * 修改一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + @Override + public int updateDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData) + { + return dcTrafficSurveyDataMapper.updateDcTrafficSurveyData(dcTrafficSurveyData); + } + + /** + * 批量删除一类交调数据 + * + * @param ids 需要删除的一类交调数据主键 + * @return 结果 + */ + @Override + public int deleteDcTrafficSurveyDataByIds(Long[] ids) + { + return dcTrafficSurveyDataMapper.deleteDcTrafficSurveyDataByIds(ids); + } + + /** + * 删除一类交调数据信息 + * + * @param id 一类交调数据主键 + * @return 结果 + */ + @Override + public int deleteDcTrafficSurveyDataById(Long id) + { + return dcTrafficSurveyDataMapper.deleteDcTrafficSurveyDataById(id); + } + + /** + * 查询所有交调设备 + * + * @param + * @return 结果 + */ + @Override + public List selectDeviceList(){ + return dcTrafficSurveyDataMapper.selectDeviceList(); + } + + /** + * 批量插入 + * + * @param batchData 一类交调数据 + * @return 结果 + */ + @Override + public int batchInsert(List batchData){ + return dcTrafficSurveyDataMapper.batchInsert(batchData); + } +} diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index c7307f7d..1712713b 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -1158,6 +1158,10 @@ public class DcWarningServiceImpl implements IDcWarningService { JsonNode roocallPostApiGetRegionstNode = objectMapper.readTree(callPostApiGetRegions); JsonNode jsonNode = roocallPostApiGetRegionstNode.get("data"); JsonNode jsonNodelist = jsonNode.get("list"); + if (jsonNodelist.isEmpty()){ + return ""; + } + JsonNode code = jsonNodelist.get(UniversalEnum.ZERO.getNumber()).get("cameraIndexCode"); // 使用 textValue() 方法获取纯字符串 String codestring = code.textValue(); diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml new file mode 100644 index 00000000..0f550b30 --- /dev/null +++ b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + select id, iot_device_id, stake_mark, direction, timestamp, traffic_volume from dc_traffic_survey_data + + + + + + + + + + + + insert into dc_traffic_survey_data + + iot_device_id, + stake_mark, + direction, + timestamp, + traffic_volume, + + + #{iotDeviceId}, + #{stakeMark}, + #{direction}, + #{timestamp}, + #{trafficVolume}, + + + + + insert into dc_traffic_survey_data + + iot_device_id, + stake_mark, + direction, + timestamp, + traffic_volume, + + + #{dcTrafficSurveyData.iotDeviceId}, + #{dcTrafficSurveyData.stakeMark}, + #{dcTrafficSurveyData.direction}, + #{dcTrafficSurveyData.timestamp}, + #{dcTrafficSurveyData.trafficVolume}, + + + + + + update dc_traffic_survey_data + + iot_device_id = #{iotDeviceId}, + stake_mark = #{stakeMark}, + direction = #{direction}, + timestamp = #{timestamp}, + traffic_volume = #{trafficVolume}, + + where id = #{id} + + + + delete from dc_traffic_survey_data where id = #{id} + + + + delete from dc_traffic_survey_data where id in + + #{id} + + + \ No newline at end of file