From de6625b48889cc7b54df113d1bbc74d5cee90c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Wed, 4 Sep 2024 12:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E6=8E=A7=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcOperLogController.java | 32 ++-------------- .../service/impl/DcOperLogServiceImpl.java | 37 ++++++++++++++++--- 2 files changed, 35 insertions(+), 34 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 693fedce..dc6a4f49 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 @@ -55,35 +55,9 @@ public class DcOperLogController extends BaseController { // @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) { - List dcOperLogs = dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime); - ArrayList operLogArrayList = new ArrayList<>(); - if (dcOperLogs==null||dcOperLogs.size()==0){ - return getDataTable(dcOperLogs); - } - String content=""; - for (DcOperLog log:dcOperLogs){ - String dcDeviceType = log.getDcDeviceType(); - if ("5".equals(dcDeviceType)){ - content="语音广播"; - }else if ("2".equals(dcDeviceType)){ - content="情报板"; - } - String jsonResult = log.getJsonResult(); - if (("[]".equals(jsonResult)|| StringUtils.isBlank(jsonResult))&&("5".equals(dcDeviceType)||"2".equals(dcDeviceType))){ - String jsonResults = String.format( - "[{\"deviceType\":%s,\"deviceName\":%s,\"result\":{\"code\":500,\"content\":\"{%s数据异常\"}}]", - log.getDcDeviceType(), log.getDcDeviceName(), content - ); - JSONArray objects = new JSONArray(jsonResults); - log.setJsonResult(objects.toString()); - log.setRemark(content+"数据异常"); - String devices = String.format("[{\"devices\":[{\"deviceType\":%s}]}]", log.getDcDeviceType()); - JSONArray devicesJson = new JSONArray(devices); - log.setOperParam(devicesJson.toString()); - } - operLogArrayList.add(log); - } - return getDataTable(operLogArrayList); + // List dcOperLogs = dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime); + + return getDataTable(dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime)); } /** 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 97c523f6..618e1382 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 @@ -1,9 +1,11 @@ package com.zc.business.service.impl; +import cn.hutool.json.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.StringUtils; import com.zc.business.domain.DcOperLog; import com.zc.business.enums.DeviceTypeEnum; import com.zc.business.enums.UniversalEnum; @@ -11,10 +13,7 @@ import com.zc.business.mapper.DcOperLogMapper; import com.zc.business.service.IDcOperLogService; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 调用功能记录Service业务层处理 @@ -43,8 +42,36 @@ public class DcOperLogServiceImpl extends ServiceImpl pageDcOperLog(DcOperLog dcOperLog, Date endTime, Date startTime) { + + PageUtils.startPage(); - return list(getDcOperLogLambdaQueryWrapper(dcOperLog, endTime, startTime)); + List dcOperLogs = list(getDcOperLogLambdaQueryWrapper(dcOperLog, endTime, startTime)); + if (dcOperLogs==null||dcOperLogs.size()==0){ + return dcOperLogs ; + } + String content=""; + for (DcOperLog log:dcOperLogs){ + String dcDeviceType = log.getDcDeviceType(); + if ("5".equals(dcDeviceType)){ + content="语音广播"; + }else if ("2".equals(dcDeviceType)){ + content="情报板"; + } + String jsonResult = log.getJsonResult(); + if (("[]".equals(jsonResult)|| StringUtils.isBlank(jsonResult))&&("5".equals(dcDeviceType)||"2".equals(dcDeviceType))){ + String jsonResults = String.format( + "[{\"deviceType\":%s,\"deviceName\":%s,\"result\":{\"code\":500,\"content\":\"{%s数据异常\"}}]", + log.getDcDeviceType(), log.getDcDeviceName(), content + ); + JSONArray objects = new JSONArray(jsonResults); + log.setJsonResult(objects.toString()); + log.setRemark(content+"数据异常"); + String devices = String.format("[{\"devices\":[{\"deviceType\":%s}]}]", log.getDcDeviceType()); + JSONArray devicesJson = new JSONArray(devices); + log.setOperParam(devicesJson.toString()); + } + } + return dcOperLogs ; } @Override