From 4c8211f3b62eb2d60eaf4b0fb34273dfe6cc8b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Fri, 6 Dec 2024 19:01:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E5=86=B5=E5=AE=9A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcTimingOfTrafficConditionsController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java index 41125a87..2b0b76ae 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java @@ -1,6 +1,8 @@ package com.zc.business.controller; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.serializer.SerializerFeature; import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcRoadConditionInformation; import com.zc.business.enums.UniversalEnum; @@ -32,9 +34,12 @@ public class DcTimingOfTrafficConditionsController { public void getTheCurrentCongestedSection() throws HttpException, IOException { // 调用服务层方法,获取当前交通指标数据 JSONArray jsonArray = dcTrafficStatisticsService.getTheCurrentCongestedSection(); - //插入 数据库 - DcRoadConditionInformation dcRoadConditionInformation =new DcRoadConditionInformation(); - dcRoadConditionInformation.setOtherConfig(jsonArray.toJSONString()); + // 序列化为 JSON 字符串,同时禁用循环引用检测 + String jsonString = JSON.toJSONString(jsonArray, SerializerFeature.DisableCircularReferenceDetect); + +// 设置 DcRoadConditionInformation 的 otherConfig 属性 + DcRoadConditionInformation dcRoadConditionInformation = new DcRoadConditionInformation(); + dcRoadConditionInformation.setOtherConfig(jsonString); dcRoadConditionInformationService.insertDcRoadConditionInformation(dcRoadConditionInformation); }