From ef46783b2facdb7faeebbfb1dacc678c7487dfae Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Wed, 28 Aug 2024 11:28:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E6=8E=A7=E8=AE=B0=E5=BD=95=E7=A9=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcOperLogController.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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 4155c72d..07fc2be0 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 @@ -10,11 +10,15 @@ import com.zc.business.domain.DcOperLog; import com.zc.business.service.IDcOperLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jdk.nashorn.internal.objects.NativeUint8Array; +import org.apache.commons.lang3.StringUtils; +import org.json.JSONArray; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -51,7 +55,35 @@ 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) { - return getDataTable(dcOperLogService.pageDcOperLog(dcOperLog, endTime, 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)){ + 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); } /**