java返给前端ECharts的格式2

java返给前端ECharts的格式2

    • 1. 返回值:值对象(Value Object)
        • 1. 带LinkedHashMap的 key Value 格式的VO
        • 2. 带X轴和Y轴的VO
        • 3. 带标签的返回值
    • 2. 业务对象BO:(Business Object)
        • 1. AreaBO
        • 2. AreaNameBO
        • 3. LegendAreaBO
        • 4.LegendNameBO
        • 5.NameBO
    • 3. EChartsUtil 工具
    • 4.枚举

1. 返回值:值对象(Value Object)

1. 带LinkedHashMap的 key Value 格式的VO

KvVOMap

package com.包名.路径.vo;import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.util.LinkedHashMap;
import java.util.Map;@Data
@NoArgsConstructor
//@AllArgsConstructor
public class KvVOMap<T> extends LinkedHashMap<String, Object> {@ApiModelProperty("key")private String k;@ApiModelProperty("value")private T v;public void setK(String k) {this.k = k;this.put("k", k);}public void setV(T v) {this.v = v;this.put("v", v);}//全参构造public KvVOMap(String k, T v) {this.k = k;this.v = v;this.put("k", k);this.put("v", v);}public KvVOMap<T> extra(Map<String, Object> extra) {if (CollUtil.isNotEmpty(extra)) {this.putAll(extra);}return this;}public KvVOMap<T> extra(String k, Object v) {if (ObjectUtil.isAllNotEmpty(new Object[]{k, v})) {this.put(k, v);}return this;}public String getK() {return this.k;}public T getV() {return this.v;}public String toString() {return "KvVOMap(k=" + this.getK() + ", v=" + this.getV() + ")";}public boolean equals(final Object o) {if (o == this) {return true;} else if (!(o instanceof KvVOMap)) {return false;} else {KvVOMap<?> other = (KvVOMap<?>)o;if (!other.canEqual(this)) {return false;} else if (!super.equals(o)) {return false;} else {Object this$k = this.getK();Object other$k = other.getK();if (this$k == null) {if (other$k != null) {return false;}} else if (!this$k.equals(other$k)) {return false;}Object this$v = this.getV();Object other$v = other.getV();if (this$v == null) {if (other$v != null) {return false;}} else if (!this$v.equals(other$v)) {return false;}return true;}}}protected boolean canEqual(final Object other) {return other instanceof KvVOMap;}public int hashCode() {int result = super.hashCode();Object $k = this.getK();result = result * 59 + ($k == null ? 43 : $k.hashCode());Object $v = this.getV();result = result * 59 + ($v == null ? 43 : $v.hashCode());return result;}
}

最终返给前端的格式,大概率是这样的
Apache ECharts

2. 带X轴和Y轴的VO

DataVO

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.util.ArrayList;
import java.util.List;@Data
@NoArgsConstructor
@AllArgsConstructor
public class DataVO<T> {@ApiModelProperty(value = "数值")private List<T> data = new ArrayList<>();@ApiModelProperty(value = "图例")private String name;public DataVO(List<T> data) {this.data = data;}
}
3. 带标签的返回值
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;import java.util.LinkedList;
import java.util.List;@Accessors(chain = true)
@Data
public class ChartVO<T> {@ApiModelProperty(value = "标签")private DataVO<String> legend = new DataVO<>();@ApiModelProperty(value = "x轴")@JsonProperty("xAxis")private DataVO<String> xAxis = new DataVO<>();@ApiModelProperty(value = "统计图数据")private List<DataVO<T>> series = new LinkedList<>();@ApiModelProperty(value = "辅助数据")private Object obj;
}

2. 业务对象BO:(Business Object)

1. AreaBO
import lombok.Data;
import lombok.NoArgsConstructor;import java.math.BigDecimal;@NoArgsConstructor
@Data
public class AreaBO {/*** 数量*/private BigDecimal num;/*** 名称*/private String name;/*** 所属区县*/private String homeArea;public AreaBO(BigDecimal num, String name) {this.num = num;this.name = name;}public AreaBO(BigDecimal num, String name, String homeArea) {this.num = num;this.name = name;this.homeArea = homeArea;}public AreaBO(BigDecimal num, String name, Integer homeArea) {this.num = num;this.name = name;this.homeArea = homeArea.toString();}
}
2. AreaNameBO
import lombok.Data;
import lombok.experimental.Accessors;import java.math.BigDecimal;@Accessors(chain = true)
@Data
public class AreaNameBO {/*** 数量*/private BigDecimal num;/*** 名称*/private String name;/*** 标签*/private String homeArea;/*** 标签1*/private String legend;public AreaNameBO() {}public AreaNameBO(BigDecimal num, String name) {this.num = num;this.name = name;}public AreaNameBO(BigDecimal num, String name, String homeArea,String legend) {this.num = num;this.name = name;this.homeArea = homeArea;this.legend = legend;}public AreaNameBO(String legend, BigDecimal num) {this.num = num;this.legend = legend;}
}
3. LegendAreaBO
import lombok.Data;
import lombok.experimental.Accessors;import java.math.BigDecimal;@Accessors(chain = true)
@Data
public class LegendAreaBO {/*** 数量*/private BigDecimal num;/*** 名称*/private String name;/*** 标签*/private String legend;/*** 所属区县*/private String homeArea;public LegendAreaBO() {}public LegendAreaBO(BigDecimal num, String name, String legend) {this.num = num;this.name = name;this.legend = legend;}public LegendAreaBO(BigDecimal num, String name, String legend, String homeArea) {this.num = num;this.name = name;this.legend = legend;this.homeArea = homeArea;}
}
4.LegendNameBO
import lombok.Data;
import lombok.experimental.Accessors;import java.math.BigDecimal;@Accessors(chain = true)
@Data
public class LegendNameBO {/*** 数量*/private BigDecimal num;/*** 名称*/private String name;/*** 标签*/private String legend;public LegendNameBO() {}public LegendNameBO(BigDecimal num, String name) {this.num = num;this.name = name;}public LegendNameBO(BigDecimal num, String name, String legend) {this.num = num;this.name = name;this.legend = legend;}public LegendNameBO(String legend,BigDecimal num) {this.num = num;this.legend = legend;}
}
5.NameBO
import cn.hutool.core.util.NumberUtil;
import lombok.Data;
import lombok.experimental.Accessors;import java.math.BigDecimal;@Accessors(chain = true)
@Data
public class NameBO {/*** 数量*/private BigDecimal num;/*** 名称*/private String name;public NameBO() {}public NameBO(BigDecimal num, String name) {this.num = NumberUtil.round(num, 4);this.name = name;}public NameBO(BigDecimal num) {this.num = num;}public void setNum(BigDecimal num) {this.num = NumberUtil.round(num, 4);}
}

3. EChartsUtil 工具

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.gas.base.enums.BaseEnum;
import com.gas.bo.*;
import com.gas.enums.AreaEnum;
import com.gas.utils.bean.GasBeanUtil;
import com.gas.utils.collection.GasCollectionUtil;
import com.gas.utils.convert.GasConvertUtil;
import com.gas.utils.enums.AreaBOEnum;
import com.gas.utils.list.GasListUtil;
import com.gas.utils.map.GasMapUtil;
import com.gas.utils.string.GasStringUtil;
import com.gas.vo.*;
import lombok.extern.slf4j.Slf4j;import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;@Slf4j
public class EChartsUtil {public static List<Integer> area(String area) {if (StrUtil.isBlank(area)) {return GasListUtil.empty();}return StrUtil.split(area, ",").stream().map(GasConvertUtil::toInt).toList();}public static List<AreaBO> areaBOMain(List<AreaBO> list) {if (GasCollectionUtil.isNotEmpty(list)) {if (list.stream().anyMatch(e -> AreaEnum.mainArea.contains(e.getHomeArea()))) {//汇总主城区数量BigDecimal sum = list.stream().filter(e -> AreaEnum.mainArea.contains(e.getHomeArea())).map(AreaBO::getNum).reduce(BigDecimal.ZERO, BigDecimal::add);list.removeIf(e -> AreaEnum.mainArea.contains(e.getHomeArea()));//添加主城区数量list.add(0, new AreaBO(sum, AreaEnum.mainAreaName, StrUtil.join(",", AreaEnum.mainArea)));}}return list;}public static List<AreaBO> areaBOCityMain(List<AreaBO> list) {return areaBOMain(list);}public static ChartVO<BigDecimal> areaBO(List<AreaBO> bos, AreaBOEnum enums, List<Integer> areas) {List<AreaBO> list = Arrays.stream(AreaEnum.values()).filter(e -> {if (GasCollectionUtil.isNotEmpty(areas)) {return areas.contains(e.getType());}return true;}).map(e ->new AreaBO(bos.stream().filter(y -> ObjectUtil.equal(y.getHomeArea(), e.getType().toString())).map(AreaBO::getNum).findFirst().orElse(BigDecimal.ZERO),e.getName(), e.getType().toString())).collect(Collectors.toList());list.forEach(e -> e.setName(AreaEnum.name(e.getHomeArea())));list.sort(Comparator.comparing(e -> AreaEnum.sort(e.getHomeArea())));//组装数据switch (enums) {case CITY -> areaBOCityMain(list);case MAIN -> areaBOMain(list);}//组装辅助数据BigDecimal sum = list.stream().map(AreaBO::getNum).reduce(BigDecimal.ZERO, BigDecimal::add);Map<String, List<CityTotalKvVO<BigDecimal, BigDecimal>>> obj = list.stream().collect(Collectors.groupingBy(AreaBO::getName,Collectors.mapping(e ->new CityTotalKvVO<>(e.getName(), e.getNum(), sum), Collectors.toList())));return areaBO(list).setObj(obj);}public static ChartVO<BigDecimal> areaBO(List<AreaBO> bos, AreaBOEnum enums) {return areaBO(bos, enums, null);}public static ChartVO<BigDecimal> areaBO(List<AreaBO> list) {ChartVO<BigDecimal> chart = new ChartVO<>();//汇总x轴List<String> xAxis = list.stream().map(AreaBO::getName).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());chart.setXAxis(new DataVO<>(xAxis));//汇总数据List<BigDecimal> series = list.stream().filter(e -> StrUtil.isNotBlank(e.getName())).map(AreaBO::getNum).collect(Collectors.toList());chart.getSeries().add(new DataVO<>(series));return chart;}public static List<LegendAreaBO> legendAreaBOSort(List<LegendAreaBO> list, Map<String, Integer> legendSort) {//List自带的排序方法list.sort(//先按区域排序,再按标签排序Comparator.comparing((LegendAreaBO e) -> AreaEnum.sort(e.getHomeArea())).thenComparing((LegendAreaBO e) -> legendSort.getOrDefault(e.getLegend(), Integer.MAX_VALUE)));return list;}public static Map<String, Map<String, BigDecimal>> legendNameBOGroup(List<LegendNameBO> bos) {return bos.stream().collect(Collectors.groupingBy(LegendNameBO::getName,LinkedHashMap::new,Collectors.groupingBy(LegendNameBO::getLegend,LinkedHashMap::new,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)))));}public static Map<String, Map<String, BigDecimal>> legendAreaBOGroup(List<LegendAreaBO> bos) {return bos.stream().collect(Collectors.groupingBy(LegendAreaBO::getHomeArea,Collectors.groupingBy(LegendAreaBO::getLegend,Collectors.mapping(LegendAreaBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)))));}/*** 主城区 + 标签 + x轴 + obj辅助数据*/public static ChartVO legendAreaBO(List<LegendAreaBO> list) {EChartsUtil.legendAreaBOMain(list);ChartVO<BigDecimal> chart = new ChartVO<>();//汇总标签List<String> legend = list.stream().map(LegendAreaBO::getLegend).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());chart.setLegend(new DataVO<>(legend));//汇总x轴List<String> xAxis = list.stream().map(LegendAreaBO::getName).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());chart.setXAxis(new DataVO<>(xAxis));//汇总数据legend.forEach(e -> {List<BigDecimal> series = list.stream().filter(y -> ObjectUtil.equal(e, y.getLegend()) && StrUtil.isNotEmpty(y.getName())).map(LegendAreaBO::getNum).collect(Collectors.toList());chart.getSeries().add(new DataVO<>(series, e));});Map<String, BigDecimal> legendMap = list.stream().collect(Collectors.groupingBy(LegendAreaBO::getLegend,Collectors.mapping(LegendAreaBO::getNum, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));//组装辅助数据Map<String, List<CityTotalKvVO<BigDecimal, BigDecimal>>> obj = list.stream().collect(Collectors.groupingBy(LegendAreaBO::getName,Collectors.mapping(e ->new CityTotalKvVO<>(e.getLegend(), e.getNum(), legendMap.get(e.getLegend())), Collectors.toList())));return chart.setObj(obj);}public static List<LegendAreaBO> legendAreaBOMain(List<LegendAreaBO> list) {if (CollUtil.isNotEmpty(list)) {//汇总主城区数量LinkedHashMap<String, BigDecimal> map = list.stream().filter(e -> AreaEnum.mainArea.contains(e.getHomeArea())).collect(Collectors.groupingBy(LegendAreaBO::getLegend,LinkedHashMap::new,Collectors.mapping(LegendAreaBO::getNum, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));//移除 路南、路北、高新区list.removeIf(e -> AreaEnum.mainArea.contains(e.getHomeArea()));//添加主城区数量List<LegendAreaBO> area = new LinkedList();map.forEach((k, v) ->area.add(new LegendAreaBO(v, AreaEnum.mainAreaName, k)));list.addAll(0, area);}return list;}public static ChartVO legendAreaBODictObj(List<LegendAreaBO> list) {list.forEach(e -> e.setName(AreaEnum.name(e.getHomeArea())));return EChartsUtil.legendAreaBO(list);}public static ChartVO legendAreaBODictObj(List<LegendAreaBO> bos, List<KvBO> dict) {Map<String, Map<String, BigDecimal>> map = legendAreaBOGroup(bos);Set<String> areas = bos.stream().map(LegendAreaBO::getHomeArea).collect(Collectors.toSet());bos = areas.stream().map(e -> dict.stream().map(y -> new LegendAreaBO(map.getOrDefault(e, GasMapUtil.empty()).getOrDefault(y.getKey(), BigDecimal.ZERO),AreaEnum.name(e), y.getValue(), e)).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());return EChartsUtil.legendAreaBO(bos);}public static <T extends BaseEnum> ChartVO legendNameBOEnumObj(List<LegendNameBO> bos,//X轴List<T> names,//标签List<String> legends) {Map<String, Map<String, BigDecimal>> map = legendNameBOGroup(bos);bos = names.stream().map(e ->legends.stream().map(y -> new LegendNameBO(map.getOrDefault(e.getValue().toString(), MapUtil.empty()).getOrDefault(y, BigDecimal.ZERO),e.getEnumName(), y)).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());return EChartsUtil.legendNameBO(bos);}public static <T extends BaseEnum> ChartVO legendAreaBOEnumObj(List<LegendAreaBO> list,//枚举ListList<T> enums,//标签排序Map<String, Integer> legendSort) {list.forEach(e -> {//区域名称e.setName(AreaEnum.name(e.getHomeArea()));BaseEnum baseEnum = enums.stream().filter(y -> ObjectUtil.equal(y.getValue().toString(), e.getLegend())).findFirst().get();if (ObjectUtil.isNotNull(baseEnum)) {e.setLegend(baseEnum.getEnumName());}});Optional.of(list.stream().map(LegendAreaBO::getHomeArea).toList()).orElse(new ArrayList<>()).forEach(e -> {//补充标签enums.forEach(y -> {boolean bool = list.stream().anyMatch(t -> ObjectUtil.equal(e + y.getEnumName(),t.getHomeArea() + t.getLegend()));if (!bool) {list.add(new LegendAreaBO(BigDecimal.ZERO, AreaEnum.name(e), y.getEnumName(), e));}});});//排序数据EChartsUtil.legendAreaBOSort(list, legendSort);return EChartsUtil.legendAreaBO(list);}public static ChartVO legendNameBO(List<LegendNameBO> list) {ChartVO chart = new ChartVO<>();//汇总标签List<String> legend = list.stream().map(LegendNameBO::getLegend).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());chart.setLegend(new DataVO<>(legend));//汇总x轴List<String> xAxis = list.stream().map(LegendNameBO::getName).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());chart.setXAxis(new DataVO<>(xAxis));//汇总数据legend.forEach(e -> {List<BigDecimal> series = list.stream().filter(y -> ObjectUtil.equal(e, y.getLegend()) && StrUtil.isNotEmpty(y.getName())).map(LegendNameBO::getNum).collect(Collectors.toList());chart.getSeries().add(new DataVO<>(series, e));});return chart;}public static List<LegendNameBO> legendNameBOSort(List<LegendNameBO> list, Map<String, Integer> legendSort) {list.sort(Comparator.comparing(e -> legendSort.get(e.getLegend())));return list;}public static <T extends BaseEnum> ChartVO legendNameBOEnumObj(List<LegendNameBO> list,List<String> names,List<T> enums,Map<String, Integer> legendSort) {list.forEach(e -> {BaseEnum baseEnum = enums.stream().filter(y -> ObjectUtil.equal(y.getValue().toString(), e.getLegend())).findFirst().get();if (ObjectUtil.isNotNull(baseEnum)) {e.setLegend(baseEnum.getEnumName());}});names.forEach(e -> {enums.forEach(y -> {boolean bool = list.stream().anyMatch(t -> ObjectUtil.equal(e + y.getEnumName(),t.getName() + t.getLegend()));if (!bool) {list.add(new LegendNameBO(BigDecimal.ZERO, e, y.getEnumName()));}});});Map<String, BigDecimal> collect = list.stream().collect(Collectors.groupingBy(LegendNameBO::getName,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));collect.forEach((k, v) -> {if (BigDecimal.ZERO.compareTo(v) == 0) {list.removeIf(e -> ObjectUtil.equal(k, e.getName()));}});list.sort(Comparator.comparing((LegendNameBO e) -> GasConvertUtil.toInt(e.getName())).thenComparing((LegendNameBO e) -> legendSort.getOrDefault(e.getLegend(), Integer.MAX_VALUE)));//组装辅助数据Map<String, List<KvVO<BigDecimal>>> obj = list.stream().collect(Collectors.groupingBy(LegendNameBO::getName,Collectors.mapping(e ->new KvVO<>(e.getLegend(), e.getNum()), Collectors.toList())));return EChartsUtil.legendNameBO(list).setObj(obj);}public static <T extends BaseEnum> ChartVO legendNameBOEnumObj(List<LegendNameBO> bos,List<T> enums) {Set<String> names = bos.stream().map(LegendNameBO::getName).collect(Collectors.toSet());Map<String, BigDecimal> map = bos.stream().collect(Collectors.toMap(e -> e.getName() + e.getLegend(), LegendNameBO::getNum));List<LegendNameBO> list = names.stream().map(e ->enums.stream().map(y -> new LegendNameBO(map.getOrDefault(e + y.getValue(), BigDecimal.ZERO),e, y.getEnumName())).collect(Collectors.toList())).flatMap(Collection::stream).toList();Map<String, BigDecimal> collect = list.stream().collect(Collectors.groupingBy(LegendNameBO::getName,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));collect.forEach((k, v) -> {if (BigDecimal.ZERO.compareTo(v) == 0) {list.removeIf(e -> ObjectUtil.equal(k, e.getName()));}});//组装辅助数据Map<String, List<KvVO<BigDecimal>>> obj = list.stream().collect(Collectors.groupingBy(LegendNameBO::getName,Collectors.mapping(e ->new KvVO<>(e.getLegend(), e.getNum()), Collectors.toList())));return EChartsUtil.legendNameBO(list).setObj(obj);}public static ChartVO legendNameBOAreaEnterprise(List<LegendNameBO> list, List<LegendNameBO> listArea, String area) {Map<String, BigDecimal> collect = list.stream().collect(Collectors.groupingBy(LegendNameBO::getName,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));collect.forEach((k, v) -> {if (BigDecimal.ZERO.compareTo(v) == 0) {list.removeIf(e -> ObjectUtil.equal(k, e.getName()));}});Map<String, BigDecimal> map = list.stream().collect(Collectors.groupingBy(LegendNameBO::getLegend,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));String areaName = AreaEnum.getAreaName(area);listArea.forEach(e ->e.setName(areaName).setNum(map.getOrDefault(e.getLegend(), BigDecimal.ZERO)));list.addAll(0, listArea);return legendNameBO(list);}public static <T extends BaseEnum> ChartVO legendNameBOAreaEnterpriseEnum(List<LegendNameBO> bos,String areaCode,List<T> enums,Map<String, Integer> legendSort) {String areaName = AreaEnum.getAreaName(areaCode);List<LegendNameBO> areaList = enums.stream().map(e ->new LegendNameBO(bos.stream().filter(y -> ObjectUtil.equal(e.getValue().toString(), y.getLegend())).map(LegendNameBO::getNum).reduce(BigDecimal.ZERO, BigDecimal::add), areaName, e.getValue().toString())).collect(Collectors.toList());Set<String> names = bos.stream().map(LegendNameBO::getName).collect(Collectors.toSet());List<LegendNameBO> list = names.stream().map(e ->enums.stream().map(y -> {LegendNameBO legendNameBO = bos.stream().filter(k -> ObjectUtil.equal(e, k.getName())).filter(k -> ObjectUtil.equal(y.getValue().toString(), k.getLegend())).findFirst().orElse(null);if (ObjectUtil.isNull(legendNameBO)) {legendNameBO = new LegendNameBO(BigDecimal.ZERO, e, y.getValue().toString());}return legendNameBO;}).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());list.addAll(0, areaList);//补第一列轴
//        enums.forEach(e -> {
//            LegendNameBO legendNameBO = areaList.stream()
//                    .filter(y -> ObjectUtil.equal(e.getValue().toString(), y.getLegend()))
//                    .findFirst()
//                    .orElse(null);
//            if (ObjectUtil.isNull(legendNameBO)) {
//                areaList.add(new LegendNameBO(BigDecimal.ZERO, areaName, e.getEnumName()));
//            } else {
//                legendNameBO.setName(areaName)
//                        .setLegend(e.getEnumName());
//            }
//        });
//list.forEach(e -> {BaseEnum baseEnum = enums.stream().filter(y -> ObjectUtil.equal(y.getValue().toString(), e.getLegend())).findFirst().get();if (ObjectUtil.isNotNull(baseEnum)) {e.setLegend(baseEnum.getEnumName());}});//补x轴
//        Optional.of(list.stream()
//                        .map(LegendNameBO::getName)
//                        .toList())
//                .orElse(new ArrayList<>())
//                .forEach(e -> {
//                    enums.forEach(y -> {
//                        boolean bool = list.stream()
//                                .anyMatch(t -> ObjectUtil.equal(e + y.getEnumName(),
//                                        t.getName() + t.getLegend()));
//                        if (!bool) {
//                            list.add(new LegendNameBO(BigDecimal.ZERO, e, y.getEnumName()));
//                        }
//                    });
//                });//        Map<String, BigDecimal> collect = list.stream()
//                .collect(Collectors.groupingBy(LegendNameBO::getName,
//                        Collectors.mapping(LegendNameBO::getNum,
//                                Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
//        collect.forEach((k, v) -> {
//            if (BigDecimal.ZERO.compareTo(v) == 0) {
//                list.removeIf(e -> ObjectUtil.equal(k, e.getName()));
//            }
//        });legendNameBOSort(list, legendSort);return legendNameBO(list);}public static ChartVO legendNameBOAreaEnterpriseDict(List<LegendNameBO> bos, List<KvBO> dict, String area) {Map<String, BigDecimal> areaMap = bos.stream().collect(Collectors.groupingBy(LegendNameBO::getLegend,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));List<LegendNameBO> areaBO = dict.stream().map(e -> new LegendNameBO(areaMap.getOrDefault(e.getKey(), BigDecimal.ZERO),AreaEnum.getAreaName(area),e.getValue())).collect(Collectors.toList());Map<String, Map<String, BigDecimal>> map = legendNameBOGroup(bos);Set<String> names = bos.stream().map(LegendNameBO::getName).collect(Collectors.toSet());bos = names.stream().map(e -> dict.stream().map(y -> new LegendNameBO(map.getOrDefault(e, GasMapUtil.empty()).getOrDefault(y.getKey(), BigDecimal.ZERO),e, y.getValue())).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());bos.addAll(0, areaBO);//组装辅助数据Map<String, List<KvVO<BigDecimal>>> obj = bos.stream().collect(Collectors.groupingBy(LegendNameBO::getName,Collectors.mapping(e ->new KvVO<>(e.getLegend(), e.getNum()), Collectors.toList())));return legendNameBO(bos).setObj(obj);}public static ChartVO nameBODateScope(List<NameBO> bos,List<String> dateScope) {List<NameBO> list = new ArrayList<>();Map<String, BigDecimal> map = bos.stream().collect(Collectors.toMap(NameBO::getName, NameBO::getNum));for (int i = 0; i < dateScope.size(); i++) {String e = dateScope.get(i);list.add(new NameBO(map.getOrDefault(e, BigDecimal.ZERO), e));}//若这里出问题,就把这段代码删了 或 注释了,再把下边的代码 解开注释List<KvBO> obj = list.stream().map(e -> new KvBO(e.getName(),e.getNum().toString())).collect(Collectors.toList());kvBOPercent(obj);obj.forEach(e -> e.setValue(e.getValue() + "%"));//        Map<String, BigDecimal> collect = list.stream()
//                .collect(Collectors.groupingBy(NameBO::getName, Collectors.mapping(NameBO::getNum,
//                        Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
//        BigDecimal sum = list.stream()
//                .map(NameBO::getNum)
//                .reduce(BigDecimal.ZERO, BigDecimal::add);
//
//        List<KvBO> obj = new ArrayList<>();
//        for (int i = 0; i < dateScope.size(); i++) {
//            String e = dateScope.get(i);
//            BigDecimal total = collect.getOrDefault(e, BigDecimal.ZERO);
//            KvBO bo = new KvBO(e, "0%");
//            if (BigDecimal.ZERO.compareTo(total) != 0) {
//                bo.setValue(NumberUtil.round(
//                        NumberUtil.mul(
//                                NumberUtil.div(total, sum), EChartsUtil.ONE_HUNDRED)
//                        , 2)
//                        + "%");
//            }
//            obj.add(bo);
//        }return nameBO(list).setObj(obj);}public static ChartVO nameBOAreaEnterprise(List<NameBO> list, NameBO bo, String areaCode) {bo.setName(AreaEnum.getAreaName(areaCode));list.add(0, bo);return nameBO(list);}public static ChartVO nameBOAreaEnterprise(List<NameBO> list, String areaCode) {list.add(0, new NameBO(list.stream().map(NameBO::getNum).reduce(BigDecimal.ZERO, BigDecimal::add), AreaEnum.getAreaName(areaCode)));return nameBO(list);}public static ChartVO nameBO(List<NameBO> list) {ChartVO chart = new ChartVO<>();//汇总x轴List<String> xAxis = list.stream().map(NameBO::getName).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());chart.setXAxis(new DataVO<>(xAxis));//汇总数据List<BigDecimal> series = list.stream().map(NameBO::getNum).collect(Collectors.toList());chart.getSeries().add(new DataVO<>(series));return chart;}public static final BigDecimal ONE_HUNDRED = new BigDecimal("100");public static ChartVO kvBOPiePercent(List<KvBO> list, Map<String, String> map) {return kvBOPie(kvBOPercent(list), map);}public static BigDecimal percent(String divisor, String dividend) {return percent(StrUtil.isNotBlank(divisor) ? new BigDecimal(divisor) : null,StrUtil.isNotBlank(dividend) ? new BigDecimal(dividend) : null);}public static BigDecimal percent(BigDecimal divisor, BigDecimal dividend) {if (ObjectUtil.isAllNotEmpty(divisor, dividend) && dividend.compareTo(BigDecimal.ZERO) != 0) {return NumberUtil.round(NumberUtil.mul(NumberUtil.div(divisor, dividend), EChartsUtil.ONE_HUNDRED), 2);}return BigDecimal.ZERO;}public static ChartVO kvBOPiePercent(List<KvBO> list) {return kvBOPie(kvBOPercent(list));}private static List<KvBO> kvBOPercent(List<KvBO> list) {BigDecimal sum = list.stream().map(e -> new BigDecimal(e.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);list.forEach(e -> {BigDecimal value = new BigDecimal(e.getValue());if (BigDecimal.ZERO.compareTo(value) != 0) {e.setValue(NumberUtil.round(NumberUtil.mul(NumberUtil.div(e.getValue(), StrUtil.toString(sum)), ONE_HUNDRED), 2).toString());} else {e.setValue("0");}});return list;}public static ChartVO kvBOPie(List<KvBO> list) {ChartVO chart = new ChartVO();//汇总标签List<String> legend = list.stream().map(KvBO::getKey).collect(Collectors.toList());chart.setLegend(new DataVO<>(legend));List<PieDataVO> pieData = list.stream().map(e -> new PieDataVO<>(e.getKey(), e.getValue())).collect(Collectors.toList());chart.setSeries(GasListUtil.toList(new DataVO<>(pieData)));return chart.setObj(list);}public static ChartVO kvBOPie(List<KvBO> list, Map<String, String> map, List<String> names) {ChartVO chartVO = kvBOPie(list, map);chartVO.getLegend().setData(names);return chartVO;}public static ChartVO kvBOPie(List<KvBO> list, Map<String, String> map) {map.forEach((k, v) -> {KvBO kvBO = list.stream().filter(e -> ObjectUtil.equal(e.getKey(), k)).findFirst().orElse(null);if (ObjectUtil.isNull(kvBO)) {list.add(new KvBO(v, "0"));} else {kvBO.setKey(v);}});return kvBOPie(list);}/*** KvBO 柱形图 折线图*/public static ChartVO kvVO(List<KvVO<BigDecimal>> bo) {ChartVO chart = new ChartVO<>();//汇总x轴List<String> xAxis = bo.stream().filter(e -> StrUtil.isNotBlank(e.getK())).map(KvVO::getK).distinct().collect(Collectors.toList());chart.setXAxis(new DataVO<>(xAxis));//汇总数据List<BigDecimal> series = bo.stream().filter(e -> StrUtil.isNotBlank(e.getK())).map(KvVO::getV).collect(Collectors.toList());chart.getSeries().add(new DataVO<>(series));return chart;}/*** KvBO 转换为饼图->处理数据** @param bo* @param div 被除数* @return*/public static ChartVO kvBOPie(List<KvBO> bo, String div) {if (StrUtil.isNotBlank(div) && GasConvertUtil.toInt(div) != 0) {bo.forEach(e -> {e.setValue(NumberUtil.div(e.getValue(), div, 2).toString());});}return kvBOPie(bo);}public static ChartVO legendNameBODateScope(List<LegendNameBO> bos, List<String> legends, List<String> dateScope) {List<LegendNameBO> list = new ArrayList<>();Map<String, Map<String, BigDecimal>> map = legendNameBOGroup(bos);for (int i = 0; i < dateScope.size(); i++) {String e = dateScope.get(i);for (int k = 0; k < legends.size(); k++) {String y = legends.get(k);list.add(new LegendNameBO(map.getOrDefault(e, GasMapUtil.empty()).getOrDefault(y, BigDecimal.ZERO), e, y));}}return legendNameBO(list);}public static ChartVO legendNameBOAreaEnterprise(List<LegendNameBO> bos, String area) {String areaName = AreaEnum.getAreaName(area);bos.addAll(0, bos.stream().collect(Collectors.groupingBy(LegendNameBO::getLegend,LinkedHashMap::new,Collectors.mapping(LegendNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)))).entrySet().stream().map(e -> new LegendNameBO(e.getValue(), areaName, e.getKey())).collect(Collectors.toList()));return legendNameBO(bos);}public static <T extends BaseEnum> ChartVO legendNameBOEnumDateScope(List<LegendNameBO> bos,List<T> enums,Map<String, Integer> legendSort,//日期偏移量List<String> dateScope) {HashMap<String, Integer> dateScopeSort = new HashMap<>();for (int i = 0; i < dateScope.size(); i++) {dateScopeSort.put(dateScope.get(i), i);}Map<String, Map<String, BigDecimal>> map = legendNameBOGroup(bos);bos = dateScope.stream().map(e -> enums.stream().map(y -> new LegendNameBO(map.getOrDefault(e, GasMapUtil.empty()).getOrDefault(y.getValue().toString(), BigDecimal.ZERO),e, y.getEnumName())).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());bos.sort(Comparator.comparing((LegendNameBO e) -> dateScopeSort.get(e.getName())).thenComparing((LegendNameBO e) -> legendSort.getOrDefault(e.getLegend(), Integer.MAX_VALUE)));return legendNameBO(bos);}private static final List<AreaEnum> AREA_LIST = GasListUtil.toList(AreaEnum.values());public static Map<String, Map<String, BigDecimal>> areaNameBOGroup(List<AreaNameBO> bos) {return bos.stream().collect(Collectors.groupingBy(AreaNameBO::getName,LinkedHashMap::new,Collectors.groupingBy(AreaNameBO::getHomeArea,LinkedHashMap::new,Collectors.mapping(AreaNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)))));};public static ChartVO areaNameBORadarEnumObj(List<AreaNameBO> bos,List<KvBO> nameBOS) {Map<String, Map<String, BigDecimal>> map = areaNameBOGroup(bos);List<AreaNameBO> list = nameBOS.stream().map(e ->AREA_LIST.stream().map(y -> new AreaNameBO(map.getOrDefault(e.getKey(), GasMapUtil.empty()).getOrDefault(y.getValue().toString(), BigDecimal.ZERO),e.getValue(), y.getType().toString(), y.getEnumName())).collect(Collectors.toList())).flatMap(Collection::stream).collect(Collectors.toList());String main = GasStringUtil.join(",", AreaEnum.mainArea);List<AreaNameBO> mainBOS = list.stream().filter(e -> AreaEnum.mainArea.contains(e.getHomeArea())).collect(Collectors.groupingBy(AreaNameBO::getName,LinkedHashMap::new,Collectors.mapping(AreaNameBO::getNum,Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)))).entrySet().stream().map(e -> new AreaNameBO(e.getValue(),e.getKey(), main, AreaEnum.mainAreaName)).collect(Collectors.toList());list.removeIf(e -> AreaEnum.mainArea.contains(e.getHomeArea()));list.addAll(mainBOS);list.sort(Comparator.comparing(e -> AreaEnum.LEGEND_SORT.getOrDefault(e.getLegend(), Integer.MAX_VALUE)));//组装辅助数据Map<String, List<KvVO<BigDecimal>>> obj = list.stream().collect(Collectors.groupingBy(AreaNameBO::getLegend,Collectors.mapping(e ->new KvVO<>(e.getName(), e.getNum()), Collectors.toList())));return EChartsUtil.legendNameBO(GasBeanUtil.copyPropertiesList(list, LegendNameBO.class)).setObj(obj);}
}

4.枚举

public interface BaseEnum<T> {T getValue();default String getEnumName() {return null;}
}
package com.gas.enums;import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.gas.base.enums.BaseEnum;
import com.gas.utils.convert.GasConvertUtil;
import com.gas.utils.obj.GasObjectUtil;
import com.gas.utils.string.GasStringUtil;
import lombok.Getter;import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;/*** 区县类型* 1:路北区 2:路南区 3:古冶区 4:开平区 5:丰南区 6:丰润区 7:高新开发区 8:迁安市 9:遵化市* 10:滦州市 11:滦南县 12:乐亭县 13:迁西县 14:玉田县 15:海港开发区 16:国际旅游岛 17:芦台开发区* 18:汉沽管理区 19:曹妃甸区 20:南堡开发区** @author zhaoyang*/
@Getter
public enum AreaEnum implements BaseEnum<Integer> {_130203(130203, 1, "路北区", 1),_130202(130202, 2, "路南区", 2),_130204(130204, 3, "古冶区", 3),_130205(130205, 4, "开平区", 4),_130207(130207, 5, "丰南区", 5),_130208(130208, 6, "丰润区", 6),_130273(130273, 7, "高新开发区", 7),_130283(130283, 8, "迁安市", 8),_130281(130281, 9, "遵化市", 9),_130284(130284, 10, "滦州市", 10),_130224(130224, 11, "滦南县", 11),_130225(130225, 12, "乐亭县", 12),_130227(130227, 13, "迁西县", 13),_130229(130229, 14, "玉田县", 14),_130274(130274, 15, "海港开发区", 15),_130290(130290, 16, "国际旅游岛", 16),_130271(130271, 17, "芦台开发区", 17),_130272(130272, 18, "汉沽管理区", 18),_130209(130209, 19, "曹妃甸区", 19),//南堡 暂时属于 曹妃甸_20(130209, 20, "南堡开发区", 20),;private final Integer region;private final Integer type;private final String name;private final Integer sort;public static final Map<String, Integer> LEGEND_SORT = Arrays.stream(AreaEnum.values()).collect(Collectors.toMap(AreaEnum::getName, AreaEnum::getSort));public static final String mainAreaName = "主城区";public static final String allAreaName = "全市";AreaEnum(Integer region, Integer type, String name, Integer sort) {this.region = region;this.type = type;this.name = name;this.sort = sort;}public static final List<String> mainArea = Arrays.stream(AreaEnum.values()).filter(e -> GasObjectUtil.equals(e, _130203, _130202, _130273)).map(AreaEnum::getType).map(GasStringUtil::toString).toList();public static final List<Integer> allArea = Arrays.stream(AreaEnum.values()).map(AreaEnum::getType).toList();public static AreaEnum of(Integer type) {return Arrays.stream(AreaEnum.values()).filter(e -> GasObjectUtil.equals(e.getType(), type)).findFirst().orElse(null);}public static String name(String type) {return name(GasConvertUtil.toInt(type));}public static String name(Integer type) {return Arrays.stream(AreaEnum.values()).filter(e -> ObjectUtil.equals(e.getType(), type)).findFirst().map(AreaEnum::getName).orElse(GasStringUtil.EMPTY);}public static Integer sort(String type) {return sort(GasConvertUtil.toInt(type));}public static Integer sort(Integer type) {return Arrays.stream(AreaEnum.values()).filter(e -> ObjectUtil.equals(e.getType(), type)).findFirst().map(AreaEnum::getSort).orElse(0);}public static Integer type(String name) {return Arrays.stream(AreaEnum.values()).filter(e -> ObjectUtil.equals(e.getName(), name)).findFirst().map(AreaEnum::getType).orElse(null);}public static boolean isMain(String area) {return StrUtil.contains(area, ",");}public static String getAreaName(String area) {return isMain(area) ? AreaEnum.mainAreaName : name(area);}public static Integer getRegionByAreaType(String type) {return Arrays.stream(AreaEnum.values()).filter(e -> Objects.equals(e.getType(), Integer.valueOf(type))).findFirst().map(AreaEnum::getRegion).orElse(null);}@Overridepublic Integer getValue() {return this.type;}@Overridepublic String getEnumName() {return this.name;}public Integer handleSort(String type) {return sort(type);}}

记录个大概

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/583874.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

析构和友元函数

1. 类的析构函数 析构函数的作用&#xff0c;用于释放该类所占用的资源&#xff08;或者说释放对象&#xff09;在类的对象使用完时&#xff08;当类的对象超出了作用域&#xff09;&#xff0c;会自动调用析构函数&#xff1b;如果是在堆区实例化的对象&#xff0c;那么当手动…

二分查找——OJ题(一)

&#x1f4d8;北尘_&#xff1a;个人主页 &#x1f30e;个人专栏:《Linux操作系统》《经典算法试题 》《C》 《数据结构与算法》 ☀️走在路上&#xff0c;不忘来时的初心 文章目录 一、二分查找1、题目讲解2、算法原理3、代码实现 二、在排序数组中查找元素的第一个和最后一个…

Mini MyBatis-Plus(下)

作者简介&#xff1a;大家好&#xff0c;我是smart哥&#xff0c;前中兴通讯、美团架构师&#xff0c;现某互联网公司CTO 联系qq&#xff1a;184480602&#xff0c;加我进群&#xff0c;大家一起学习&#xff0c;一起进步&#xff0c;一起对抗互联网寒冬 最核心的内容前两篇已经…

docker 安装可视化工具 Protainer 以及 汉化

一、创建保存数据的卷 安装网址&#xff1a;Install Portainer BE with Docker on Linux - Portainer Documentation docker pull portainer/portainer二、根据portainer镜像创建容器 docker run -d -p 8000:8000 -p 9000:9000\ --name portainer --restartalways \ -v /var/r…

深入ArkUI:深入实战组件text和text input

文章目录 Text组件介绍Text组件的属性方法Text:文本显示组件4.3TextInput组件实战案例:图片宽度控制页面本文总结要点回顾在今天的课程中,我们将深入学习ArkUI提供的基础组件,着重探讨text和text input两个组件。 Text组件介绍 Text组件是一个用于显示文本的组件,其主要作…

VSCode安装Go环境

VSCode安装Go 1.点击Go官网&#xff0c;根据自己环境下载go安装包&#xff0c;我这里为Windows 2.双击安装包&#xff0c;一直点击【Next】即可 VSCode配置Go基础环境 1.创建Go的工作目录: C:\Code\GoCode 2.创建Go的环境变量: GOPATH (1)右键【此电脑】&#xff0c;点击…

C/C++转WebAssembly及微信小程序调用

上一篇文章讲了C/C如何转WebAssembly&#xff0c;并测试了在Web端调用。本篇内容和上篇一样&#xff0c;介绍C/C包转的.wasm包如何在小程序中调用。 说明 本篇是在上一篇步骤1-4的基础上&#xff0c;再做修改&#xff0c;供微信小程序端调用的方法和步骤。 本篇操作手册可以…

Python自动化测试:选择最佳的自动化测试框架

在开始学习python自动化测试之前&#xff0c;先了解目前市场上的自动化测试框架有哪些&#xff1f; 随着技术的不断迭代更新&#xff0c;优胜劣汰也同样发展下来。从一开始工具型自动化&#xff0c;到现在的框架型&#xff1b;从一开始的能用&#xff0c;到现在的不仅能用&…

鸿蒙问题之本地模拟器无法识别

今天按例打开本地模拟器&#xff0c;发现DevEco Studio不能检测到我的本地模拟器了。 重启了DevEco Studio和模拟器多次都无果。果断删除模拟器 然后创建一个新的&#xff0c;就可以成功检测到了。这应该是idea的一个bug

关于python解析mf4中二维信号数据的注意事项

python解析mf4中的信号数据一般用np.ndarray存储&#xff0c;但是mf4中的一个信号有时不一定是一维数据&#xff0c;有时会是一个二维的&#xff0c;没错&#xff0c;就是一个信号数据就是二维的&#xff0c;这时候&#xff0c;np数组的每个元素也是一个数组&#xff0c;这个时…

整数除法相关用法:floor、ceil、round

整数除法——舍小数&#xff0c;取整数 1.floor()头文件<math.h> 功能&#xff1a;把一个小数向下取整&#xff0c;即就是如果数是2.2 &#xff0c;那向下取整的结果就为2.000000 原型&#xff1a;double floor(doube x); x : 是需要计算的数 返回值&#xff1a; 成…

【揭秘】如何制作推拉门电子画册,轻松成为行业大咖!

​在当今数字化时代&#xff0c;电子画册已成为企业展示产品、服务的重要手段。与传统印刷画册相比&#xff0c;电子画册具有诸多优势&#xff0c;如易于传播、易于更新、环保低碳等。更重要的是&#xff0c;通过电子画册&#xff0c;企业可以更好地与目标受众互动&#xff0c;…

K8s - Helm、HPA、rancher

目录 1、什么是 Helm 2、Helm 部署 3、Helm 自定义模板 4、Helm 仓库 5、HPA 6、部署 metrics-server 7、Rancher 管理 Kubernetes 集群 8、Rancher 安装及配置 1、什么是 Helm 在没使用 helm 之前&#xff0c;向 kubernetes 部署应用&#xff0c;我们要依次部署 depl…

天津医科大学临床医学院专升本药学专业有机化学考试大纲

天津医科大学临床医学院高职升本科专业课考试大纲药学专业《有机化学》科目考试大纲 一、考试基本要求 本考试大纲主要要求考生对《有机化学》基本概念有较深入的了解&#xff0c;能够系统地掌握各类化合物的命名、结构特点及立体异构、主要性质、反应、来源和合成制备方法等…

SQL面试题挑战11:访问会话切割

目录 问题&#xff1a;SQL解答&#xff1a; 问题&#xff1a; 如下为某电商公司用户访问网站的数据&#xff0c;包括用户id和访问时间两个字段。现有如下规则&#xff1a;如果某个用户的连续的访问记录时间间隔小于60秒&#xff0c;则属于同一个会话&#xff0c;现在需要计算每…

相对于一般的统计学,计量经济学的特色是什么?谈Stata与计量经济学

Stata作为一种数据分析软件&#xff0c;高度适用于依托计量经济学的研究领域&#xff0c;如宏观经济学、财政学等&#xff0c;当然在医学等学科应用也较为广泛&#xff0c;在处理面板数据方面也深具特色。计量经济学是指运用概率统计方法对经济变量之间的因果关系进行定量分析的…

idea的pom.xml文件灰色删除线解决办法

以上是点击了移除module后就变成这样 如果再次对着已移除的module右键会发现有个delete&#xff0c;点击这个是真删了&#xff0c;要谨慎备份哦 解决方案&#xff1a;恢复误操作remove module的解决方法 idea最右边&#xff0c;有个Maven控件&#xff0c;找到要恢复的module&a…

vscode连接linux服务器

目录 下载vscode&#xff0c;这是微软开源软件&#xff0c;打开后到下载扩展页面 在下载扩展页面下载中文和ssh远程连接扩展 安装后会在左边新生成一个图标点击齿轮 选择第一个 配置连接信息 远程隧道右边刷新&#xff0c;等刷出来hostname的主机后 连接ip出来后&#x…

mybatisX自动生成sql语句,尝试测试方法报错

今天我使用mybatisx自定义mapper方法生成sql语句后&#xff0c;在测试时报错 错误是MyBatis 无法找到映射的语句&#xff08;Statement&#xff09;引起的 我是这样操作的&#xff0c;在mapper接口自定义了一个方法 然后alt加enter&#xff0c;自动生成sql 结果 mapper.xml文件…

骨传导耳机的原理是什么?一文读懂骨传导耳机优缺点都有哪些!

一、骨传导耳机传声原理是什么 骨传导耳机以人体骨骼为传声介质&#xff0c;可以将声音转化为不同频率的震动&#xff0c;在不经过外耳道和鼓膜的情况下&#xff0c;通过震动使声音经过内耳道&#xff0c;直接传入大脑听觉神经&#xff0c;与传统耳机相比&#xff0c;可以节省许…