diff --git a/indicator/src/main/java/com/indicator/controller/IndicatorController.java b/indicator/src/main/java/com/indicator/controller/IndicatorController.java index a257c12..7f73879 100644 --- a/indicator/src/main/java/com/indicator/controller/IndicatorController.java +++ b/indicator/src/main/java/com/indicator/controller/IndicatorController.java @@ -74,7 +74,10 @@ public class IndicatorController { setSuccess(result); if(list != null){ - result.setData(list); + HashMap hashMap =new HashMap<>(); + hashMap.put("data", list); + hashMap.put("totalCount", result.getTotal()); + result.setData(hashMap); if(result.getTotal() == null){ result.setTotal((long) list.size()); } @@ -459,30 +462,37 @@ public class IndicatorController { } if(label_list != null && label_list.size()>0){ + boolean saveTmpFlag = false; for (int i = 0; i < label_list.size(); i++) { if(!updateFlag){ if(i > 0 && i <(label_list.size())) { label_list.get(i).setParentId(label_list.get(i-1).getId()); } label_list.get(i).setCreateTime(date); + saveTmpFlag = true; }else { if (label_list.get(i).getId() == null) { - log.error("-------- 保存指标异常, 更新指标时, 标签id不能为空" + label_list.get(i)); - throw new RuntimeException("更新指标时, 标签id不能为空" + label_list.get(i)); - } - List I_L_list =indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId,indicator.getId()).list(); - boolean ILFlag = false; - for (int j=0; j 0 && i <(label_list.size())) { + label_list.get(i).setParentId(label_list.get(i-1).getId()); } + label_list.get(i).setCreateTime(date); + saveTmpFlag = true; + } else { + List I_L_list = indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId, indicator.getId()).list(); + boolean ILFlag = false; + for (int j = 0; j < I_L_list.size(); j++) { + if (label_list.get(i).getId().equals(I_L_list.get(j).getLabelId())) { + ILFlag = true; + } + } + if (!ILFlag) { + log.error("-------- 保存指标异常, 更新指标id : " + label_list.get(i).getId() + "无效,请输入正确的指标id"); + throw new RuntimeException("更新指标id : " + label_list.get(i).getId() + "无效,请输入正确的指标id"); + } + Label label = labelRepository.getById(label_list.get(i).getId()); + label_list.get(i).setParentId(label.getParentId()); } - if(!ILFlag){ - log.error("-------- 保存指标异常, 更新指标id : "+label_list.get(i).getId()+"无效,请输入正确的指标id"); - throw new RuntimeException("更新指标id : "+label_list.get(i).getId()+"无效,请输入正确的指标id"); - } - Label label = labelRepository.getById(label_list.get(i).getId()); - label_list.get(i).setParentId(label.getParentId()); } label_list.get(i).setTableName(tableName); label_list.get(i).setUpdateTime(date); @@ -493,7 +503,7 @@ public class IndicatorController { System.out.println("___"+label_list.get(i).getId()); if(label_flag){ - if(!updateFlag){ + if(!updateFlag || saveTmpFlag){ IndicatorLabel indicator_label = new IndicatorLabel(); indicator_label.setIndicatorId(indicator.getId()); indicator_label.setLabelId(label_list.get(i).getId()); @@ -624,7 +634,7 @@ public class IndicatorController { public Result searchIndicator(@RequestBody Search search) { Result result = new Result(); try { - Page query = new Page(search.getCurrentPage(), search.getPageSize()); + Page query = new Page(search.getCurrentPage()-1, search.getPageSize()); Page page = indicatorMapper.getIndicatorPage(query,search.getValue()); for (IndicatorVo vo : page.getRecords()) { LambdaQueryChainWrapper wrapper = indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId,vo.getId()); @@ -632,7 +642,7 @@ public class IndicatorController { for (IndicatorLabel indicatorLabel : wrapper.select(IndicatorLabel::getLabelId).list()) { list.add(indicatorLabel.getLabelId()); } - List