From 8a354b602cc6f7b707cd93250dd23152cce85141 Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Wed, 17 May 2023 14:44:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E9=9B=86=E5=8F=AA=E4=BF=9D=E7=95=99=E4=B8=80=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DataSetServiceImpl.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/service/impl/DataSetServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/service/impl/DataSetServiceImpl.java index d53474e8..087f5279 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/service/impl/DataSetServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/service/impl/DataSetServiceImpl.java @@ -152,6 +152,19 @@ public class DataSetServiceImpl implements DataSetService { //1.新增数据集 DataSet dataSet = new DataSet(); BeanUtils.copyProperties(dto, dataSet); + if (StringUtils.isNotBlank(dataSet.getCaseResult())) { + try { + JSONArray objects = JSONObject.parseArray(dataSet.getCaseResult()); + if (objects.size() > 1) { + Object o = objects.get(0); + objects = new JSONArray(); + objects.add(o); + dataSet.setCaseResult(objects.toJSONString()); + } + } catch (Exception e) { + log.info("结果集只保留一行数据失败...{}", e.getMessage()); + } + } insert(dataSet); //2.更新查询参数 dataSetParamBatch(dataSetParamDtoList, dto.getSetCode()); @@ -174,6 +187,19 @@ public class DataSetServiceImpl implements DataSetService { //1.更新数据集 DataSet dataSet = new DataSet(); BeanUtils.copyProperties(dto, dataSet); + if (StringUtils.isNotBlank(dataSet.getCaseResult())) { + try { + JSONArray objects = JSONObject.parseArray(dataSet.getCaseResult()); + if (objects.size() > 1) { + Object o = objects.get(0); + objects = new JSONArray(); + objects.add(o); + dataSet.setCaseResult(objects.toJSONString()); + } + } catch (Exception e) { + log.info("结果集只保留一行数据失败...{}", e.getMessage()); + } + } update(dataSet); //2.更新查询参数 @@ -328,10 +354,6 @@ public class DataSetServiceImpl implements DataSetService { List data = dataSourceService.execute(dataSourceDto); //5.数据转换 List transform = dataSetTransformService.transform(dto.getDataSetTransformDtoList(), data); - //测试结果只保留list(0) - if (!CollectionUtils.isEmpty(transform) && transform.size() > 1) { - transform = Collections.singletonList(transform.get(0)); - } originalDataDto.setData(transform); return originalDataDto; }