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); }