Browse Source

Merge branch 'master' of http://nokia.tianhaikj.tk:13000/other/hb_nokia_pm_ui

wangrulan 1 year ago
parent
commit
8cd915d0e1

+ 18 - 0
src/main/java/com/nokia/hb/dao/mapper/PerCfgIndicatorMapper.java

@@ -2,10 +2,13 @@ package com.nokia.hb.dao.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.nokia.hb.dao.entity.PerCfgIndicator;
+import com.nokia.hb.pojo.bo.IndicatorTemplateItemBo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -24,4 +27,19 @@ public interface PerCfgIndicatorMapper extends BaseMapper<PerCfgIndicator> {
      */
     @Select("select * from pm_parse.per_cfg_indicator order by sort desc")
     List<PerCfgIndicator> all();
+
+    /**
+     * 通过id列表查询indicator_en
+     *
+     * @param list 列表
+     * @return {@link Set}<{@link String}>
+     */
+    @Select("<script>"
+            + " select indicator_en from pm_parse.per_cfg_indicator"
+            + " where indicator_id in"
+            + " <foreach open=\"(\" close=\")\" collection=\"list\" item=\"item\" separator=\",\">"
+            + "   #{item}"
+            + " </foreach>"
+            + " </script>")
+    Set<String> listByIds(@Param("list") Set<Long> list);
 }

+ 1 - 1
src/main/java/com/nokia/hb/pojo/dto/RenderTableDto.java

@@ -25,7 +25,7 @@ public class RenderTableDto {
     private TimeTypeEnum timeType;
     @Schema(description = "指标")
     @NotEmpty(message = "indicators不能为空")
-    private Set<String> indicators;
+    private Set<Long> indicators;
     @Schema(description = "起始时间", example = "2022-11-01 13:00:00", required = true)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Past(message = "startTime不能大于当前时间")

+ 1 - 1
src/main/java/com/nokia/hb/pojo/vo/GetTemplateDetailVo.java

@@ -13,7 +13,7 @@ import java.util.List;
 @Data
 public class GetTemplateDetailVo {
     @Schema(description = "模板id")
-    private Long id;
+    private String id;
     @Schema(description = "模板名称")
     private String templateName;
     @Schema(description = "指标列表")

+ 15 - 16
src/main/java/com/nokia/hb/service/IndicatorService.java

@@ -22,39 +22,38 @@ public class IndicatorService {
     }
 
     public R<List<TreeNode>> initTreeIndicator() {
-        List<PerCfgIndicator> indicators = perCfgIndicatorMapper.all();
-        Map<String, List<TreeNode>> m = new HashMap<>();
         TreeNode allTree = new TreeNode("指标选择", "指标选择", new ArrayList<>());
         allTree.setSpread(true);
-        List<TreeNode> res = new ArrayList<>();
-        res.add(allTree);
-        indicators.forEach(i -> {
-            String indicatorType = i.getIndicatorType();
-            String indicatorCn = i.getIndicatorCn();
-            String indicatorId = String.valueOf(i.getIndicatorId());
-            TreeNode t = new TreeNode(indicatorCn, indicatorId, null);
-            m.putIfAbsent(indicatorType, new ArrayList<>());
-            m.get(indicatorType).add(t);
-        });
-        m.forEach((k, v) -> allTree.getChildren().add(new TreeNode(k, k, v)));
+        List<TreeNode> res = getTreeNodes(allTree);
         return R.ok(res);
     }
 
     public R<List<TreeNode>> allIndicator() {
+        TreeNode allTree = new TreeNode("所有指标", "所有指标", new ArrayList<>());
+        List<TreeNode> res = getTreeNodes(allTree);
+        return R.ok(res);
+    }
+
+    /**
+     * 生成指标树节点
+     *
+     * @param allTree 所有树
+     * @return {@link List}<{@link TreeNode}>
+     */
+    private List<TreeNode> getTreeNodes(TreeNode allTree) {
         List<PerCfgIndicator> indicators = perCfgIndicatorMapper.all();
         Map<String, List<TreeNode>> m = new HashMap<>();
-        TreeNode allTree = new TreeNode("所有指标", "所有指标", new ArrayList<>());
         List<TreeNode> res = new ArrayList<>();
         res.add(allTree);
         indicators.forEach(i -> {
             String indicatorType = i.getIndicatorType();
             String indicatorCn = i.getIndicatorCn();
-            String indicatorId = i.getIndicatorEn();
+            String indicatorId = String.valueOf(i.getIndicatorId());
             TreeNode t = new TreeNode(indicatorCn, indicatorId, null);
             m.putIfAbsent(indicatorType, new ArrayList<>());
             m.get(indicatorType).add(t);
         });
         m.forEach((k, v) -> allTree.getChildren().add(new TreeNode(k, k, v)));
-        return R.ok(res);
+        return res;
     }
 }

+ 2 - 2
src/main/java/com/nokia/hb/service/IndicatorTemplateService.java

@@ -59,7 +59,7 @@ public class IndicatorTemplateService {
             TreeNode t = new TreeNode(templateName, String.valueOf(id), new ArrayList<>());
             allTree.getChildren().add(t);
             List<IndicatorTemplateItemBo> bos = map.get(id);
-            bos.forEach(b -> t.getChildren().add(new TreeNode(b.getIndicatorCn(), b.getIndicatorEn())));
+            bos.forEach(b -> t.getChildren().add(new TreeNode(b.getIndicatorCn(), String.valueOf(b.getIndicatorId()))));
         });
         return R.ok(res);
     }
@@ -122,7 +122,7 @@ public class IndicatorTemplateService {
         }
         List<TreeNode> list = indicatorTemplateItemMapper.listByTemplateId(dto.getId());
         GetTemplateDetailVo vo = new GetTemplateDetailVo();
-        vo.setId(indicatorTemplate.getId());
+        vo.setId(String.valueOf(indicatorTemplate.getId()));
         vo.setTemplateName(indicatorTemplate.getTemplateName());
         vo.setList(list);
         return R.ok(vo);

+ 4 - 1
src/main/java/com/nokia/hb/service/PmService.java

@@ -30,7 +30,10 @@ public class PmService {
 
     public R<RetData> renderTable(RenderTableDto dto, HttpSession session) {
         List<Map<String, Object>> list = new ArrayList<>();
-        String indicators = String.join(",", dto.getIndicators());
+        Set<String> indicatorSet = perCfgIndicatorMapper.listByIds(dto.getIndicators());
+        indicatorSet.add("eci");
+        indicatorSet.add("sdate");
+        String indicators = String.join(",", indicatorSet);
         // 按地市查询
         if (SearchTypeEnum.AREA.equals(dto.getSearchType())) {
             // 获取拥有的城市权限

+ 0 - 3
src/main/resources/templates/template.html

@@ -520,11 +520,8 @@
                     indicators.add(ee.id)
                 })
             });
-            indicators.add('eci')
-            indicators.add('sdate')
             let timeType = $('#timeType').val()
             let sdate = $('#time1').val()
-            console.log('sdate: ', sdate);
             const [startTime, endTime] = sdate.split(' - ')
             renderTable(condition, searchType, table, citys, quxians, indicators, timeType, startTime, endTime)
             return false;