diff options
| author | tanghao <admin@LAPTOP-QCSKVLI9> | 2021-06-03 10:13:06 +0800 |
|---|---|---|
| committer | tanghao <admin@LAPTOP-QCSKVLI9> | 2021-06-03 10:13:06 +0800 |
| commit | cad1749a65c9ad418a3cf9d00a024103438f20f7 (patch) | |
| tree | e269d23bc336bdf859f27bf980ae68a1952c332a | |
| parent | 5ab58dbacbd3fca1088158836394eb8d8ca5c57c (diff) | |
fix: 修复图表同步组重复同步不成功bug
| -rw-r--r-- | nz-admin/src/main/java/com/nis/modules/panel/service/impl/VisualChartServiceImpl.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/nz-admin/src/main/java/com/nis/modules/panel/service/impl/VisualChartServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/panel/service/impl/VisualChartServiceImpl.java index 4ea423cd..00e9eb39 100644 --- a/nz-admin/src/main/java/com/nis/modules/panel/service/impl/VisualChartServiceImpl.java +++ b/nz-admin/src/main/java/com/nis/modules/panel/service/impl/VisualChartServiceImpl.java @@ -958,11 +958,12 @@ public class VisualChartServiceImpl extends ServiceImpl<VisualChartDao, VisualCh syncChart.setElements(copyElements); result.add(syncChart); if(syncChart.getType().equals(Constant.CHART_GROUP_TYPE)) { - // 当chart为group时 不允许name重复 会影响chart批量导入 - List<VisualChart> charts = this.list(new QueryWrapper<VisualChart>().lambda().eq(VisualChart::getName, syncChart.getName()).eq(VisualChart::getType, Constant.CHART_GROUP_TYPE.toString()).eq(VisualChart::getPanelId, syncChart.getPanelId()).ne(ToolUtil.isNotEmpty(syncChart.getId()), VisualChart::getId,syncChart.getId())); - if(ToolUtil.isNotEmpty(charts)) { - throw new NZException(RCode.CHART_GROUP_NAME_DUPLICATE); - } + // 当chart为group时 不允许name重复 + VisualChart chart = this.getOne(new QueryWrapper<VisualChart>().lambda().eq(VisualChart::getName, syncChart.getName()).eq(VisualChart::getType, Constant.CHART_GROUP_TYPE.toString()).eq(VisualChart::getPanelId, syncChart.getPanelId()).ne(ToolUtil.isNotEmpty(syncChart.getId()), VisualChart::getId,syncChart.getId())); + if(ToolUtil.isNotEmpty(chart)) { + // group chart不能重复 先将group删除 防止不能创建组 + this.removeById(chart.getId()); + } } this.save(syncChart); List<VisualChartElement> tmplChartElements = new ArrayList<VisualChartElement>(); |
