From 3046781b4edeaf08619095a18f6ca355eeaf1329 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Wed, 11 Oct 2023 18:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=AD=E6=B2=A3=E7=A7=91=E6=8A=80=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=88=86=E6=9E=90=E9=97=A8=E6=88=B7=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E9=A5=BC=E5=9B=BE=20=E6=9F=B1=E7=8A=B6=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/matfron/entity/OptionVO.java | 18 +- .../service/StatisticsPortalService.java | 4 +- .../impl/StatisticsPortalServiceImpl.java | 202 +++++++++++------- .../matfron/web/StatisticsPortalAction.java | 5 +- src/test/MainTest.java | 18 +- 5 files changed, 146 insertions(+), 101 deletions(-) diff --git a/src/com/engine/matfron/entity/OptionVO.java b/src/com/engine/matfron/entity/OptionVO.java index e0e16f1..3c5baa7 100644 --- a/src/com/engine/matfron/entity/OptionVO.java +++ b/src/com/engine/matfron/entity/OptionVO.java @@ -5,7 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.TreeSet; +import java.util.LinkedList; /** * @Author liang.cheng @@ -22,7 +22,7 @@ public class OptionVO { private String titleText; - private TreeSet xData; + private LinkedList xData; private Integer yMin; @@ -30,18 +30,18 @@ public class OptionVO { private Integer yInterval; - private TreeSet yData; + private LinkedList yData; - private TreeSet legendDataFirst; + private LinkedList legendDataFirst; - private TreeSet legendDataTwo; + private LinkedList legendDataTwo; - private TreeSet barSeriesData; + private LinkedList barSeriesData; - private TreeSet barSeriesDataTwo; + private LinkedList barSeriesDataTwo; - private TreeSet barSeriesDataThree; + private LinkedList barSeriesDataThree; - private TreeSet seriesData; + private LinkedList seriesData; } diff --git a/src/com/engine/matfron/service/StatisticsPortalService.java b/src/com/engine/matfron/service/StatisticsPortalService.java index 5d2a891..45faf3d 100644 --- a/src/com/engine/matfron/service/StatisticsPortalService.java +++ b/src/com/engine/matfron/service/StatisticsPortalService.java @@ -3,8 +3,8 @@ package com.engine.matfron.service; import com.engine.matfron.entity.OptionVO; import com.engine.matfron.entity.PortalTopVO; +import java.util.LinkedList; import java.util.Map; -import java.util.TreeSet; /** @@ -22,7 +22,7 @@ public interface StatisticsPortalService { * @param: [] * @return: com.engine.matfron.entity.PortalTopVO */ - TreeSet getPortalTop(); + LinkedList getPortalTop(); /** * @Description: 一级部门人数统计 diff --git a/src/com/engine/matfron/service/impl/StatisticsPortalServiceImpl.java b/src/com/engine/matfron/service/impl/StatisticsPortalServiceImpl.java index d83193c..7449ba3 100644 --- a/src/com/engine/matfron/service/impl/StatisticsPortalServiceImpl.java +++ b/src/com/engine/matfron/service/impl/StatisticsPortalServiceImpl.java @@ -11,6 +11,7 @@ import weaver.conn.RecordSet; import weaver.general.Util; import weaver.hrm.company.DepartmentComInfo; +import java.text.DecimalFormat; import java.time.LocalDate; import java.time.Period; import java.time.YearMonth; @@ -31,9 +32,9 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override - public TreeSet getPortalTop() { + public LinkedList getPortalTop() { RecordSet rs = new RecordSet(); - TreeSet portalTopVOList = new TreeSet<>(); + LinkedList portalTopVOList = new LinkedList<>(); rs.executeQuery("select count(1) as count from hrmresource where status < 4"); rs.next(); @@ -46,12 +47,14 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo while (rs.next()) { birthdayList.add(Util.null2String(rs.getString("birthday"))); } + DecimalFormat df = new DecimalFormat("#.00"); double averageAge = birthdayList.stream() .map(CommonUtils::parseLocalDate) .mapToInt(CommonUtils::calculateAge) .average() .orElse(0); - portalTopVOList.add(PortalTopVO.builder().title("平均年龄").count(averageAge).build()); + String avgAge = df.format(averageAge); + portalTopVOList.add(PortalTopVO.builder().title("平均年龄").count(avgAge).build()); String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now())); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); @@ -66,29 +69,26 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getPortalDepartment() { RecordSet rs = new RecordSet(); - TreeSet xData = new TreeSet<>(); - TreeSet yData = new TreeSet<>(); + LinkedList xData = new LinkedList<>(); + LinkedList yData = new LinkedList<>(); List ids = new ArrayList<>(); - rs.executeQuery("select id,departmentname from hrmdepartment where supdepid = 0"); + rs.executeQuery("select id,departmentname from hrmdepartment where supdepid = 0 and (canceled = 0 or canceled is null)"); while (rs.next()) { xData.add(Util.null2String(rs.getString("departmentname"))); ids.add(Util.getIntValue(rs.getString("id"))); } List deptList = new ArrayList<>(); - rs.executeQuery("select departmentid,count(1) AS count from hrmresource where status < 4 and departmentid in ("+StringUtils.join(ids,",")+") group by departmentid"); + rs.executeQuery("SELECT d.id, CASE WHEN t.count IS NULL THEN 0 ELSE t.count END AS num \n" + + " FROM hrmdepartment d left join (SELECT departmentid, COUNT(1) AS count FROM hrmresource where status < 4 GROUP BY departmentid) t ON d.id = t.departmentid \n" + + " where d.id in ("+StringUtils.join(ids,",")+")"); while (rs.next()) { - deptList.add(DepartmentParam.builder().departmentId(Util.getIntValue(rs.getString("departmentid"))).count(Util.getIntValue(rs.getString("count"))).build()); + int num = Util.getIntValue(rs.getString("num")); + yData.add(num); + deptList.add(DepartmentParam.builder().departmentId(Util.getIntValue(rs.getString("id"))).count(num).build()); } - ids.forEach(item -> deptList.forEach(dept -> { - if (dept.getDepartmentId().equals(item)) { - yData.add(dept.getCount()); - }else { - yData.add(0); - } - })); int max = Collections.max(yData); int ceil =(int) Math.ceil((double) max / 5); @@ -108,16 +108,18 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getPortalSubCompany() { RecordSet rs = new RecordSet(); - TreeSet yData = new TreeSet<>(); + LinkedList yData = new LinkedList<>(); List yearMonths = CommonDateUtil.getYearMonths(LocalDate.now()); yearMonths.forEach(yearMonth -> { String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth)); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth)); - rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate >= ? and companystartdate <= ?",startMonth,endMonth); - rs.next(); - Integer sum = Util.getIntValue(rs.getString("sum"),0); - yData.add(sum); + rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ?",endMonth); + if (rs.next()) { + Integer sum = Util.getIntValue(rs.getString("sum"),0); + yData.add(sum); + } + }); int max = Collections.max(yData); @@ -137,30 +139,27 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getPortalEthnic() { RecordSet rs = new RecordSet(); - List colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9","#faf0e6","#7cfc00","#ao20f0","#9933fa"); - TreeSet seriesData = new TreeSet<>(); - TreeSet nameSet = new TreeSet<>(); + List colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9","#faf0e6","#7cfc00","#ao20f0","#9933fa","#c0ff3e","#00ced1","#ffe4c4","#cd6090"); + LinkedList seriesData = new LinkedList<>(); + LinkedList nameSet = new LinkedList<>(); rs.executeQuery("select distinct folk,count(1) as sums from hrmresource where status < 4 \n" + " and folk is not null group by folk"); - int index = 0; while (rs.next()) { - if (index > colorList.size()){ - index = 0; - } - index++; - String name = Util.null2String(rs.getString("name")); + Random random = new Random(); + String color = colorList.get(random.nextInt(colorList.size())); + String name = Util.null2String(rs.getString("folk")); seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sums"))) - .name(name).color(colorList.get(index)).build()); + .name(name).color(color).build()); nameSet.add(name); } - TreeSet legendDataFirst = null; + LinkedList legendDataFirst = null; if (nameSet.size() > 2) { int splitSize = nameSet.size() / 2; legendDataFirst = nameSet.stream() - .collect(Collectors.partitioningBy(e -> nameSet.headSet(e).size() < splitSize, - Collectors.toCollection(TreeSet::new))) + .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize, + Collectors.toCollection(LinkedList::new))) .get(false); nameSet.removeAll(legendDataFirst); } @@ -176,51 +175,60 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getHomePlace() { RecordSet rs = new RecordSet(); - List colorList = Arrays.asList("#ao20f0","#8ac9e9","#697695","#83d8ae","#faf0e6","#7cfc00","#6e94f3","#9933fa"); - TreeSet seriesData = new TreeSet<>(); - TreeSet legendData = new TreeSet<>(); + List colorList = Arrays.asList("#ao20f0","#8ac9e9","#697695","#83d8ae","#faf0e6","#7cfc00","#6e94f3","#9933fa","#c0ff3e","#00ced1","#ffe4c4","#cd6090"); + LinkedList seriesData = new LinkedList<>(); + LinkedList legendData = new LinkedList<>(); rs.executeQuery("select h.locationid,l.locationname,count(1) as num from hrmresource h\n" + " left join hrmlocations l on h.locationid = l.id\n" + - " where h.status < 4 and h.locationid is not null group by h.locationid"); + " where h.status < 4 and h.locationid is not null group by h.locationid,l.locationname"); while (rs.next()) { String locationname = Util.null2String(rs.getString("locationname")); legendData.add(locationname); - //seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("num"))).name(locationname).color(colorList.get(new Random(colorList.size())))); + Random random = new Random(); + String color = colorList.get(random.nextInt(colorList.size())); + seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("num"))).name(locationname).color(color).build()); } - return null; + + List values = seriesData.stream().map(SeriesParam :: getValue).collect(Collectors.toList()); + int percentage = values.stream().mapToInt(Integer::intValue).sum(); + seriesData.forEach(item -> item.setValue(item.getValue() / percentage)); + + return OptionVO.builder() + .titleText("归属地分析") + .legendDataFirst(legendData) + .seriesData(seriesData) + .build(); } @Override public OptionVO getEducational() { RecordSet rs = new RecordSet(); List colorList = Arrays.asList("#ee8164","#f19c45","#6fcecf","#507ef7","#faf0e6","#7cfc00","#ao20f0","#9933fa"); - TreeSet seriesData = new TreeSet<>(); - TreeSet nameSet = new TreeSet<>(); + LinkedList seriesData = new LinkedList<>(); + LinkedList nameSet = new LinkedList<>(); rs.executeQuery("select distinct h.educationlevel,count(1) as sum,d.name from hrmresource h\n" + "left join hrmeducationlevel d on h.educationlevel = d.id where status < 4 \n" + - "and h.educationlevel is not null and d.name is not null group by h.educationlevel"); + "and h.educationlevel is not null and d.name is not null group by h.educationlevel,d.name "); int index = 0; while (rs.next()) { if (index > colorList.size()){ index = 0; } index++; - String name = Util.null2String(rs.getString("name")); - if (name.contains("~")) { - name = chineseSubstringExample(name); - } + String name = Util.formatMultiLang (Util.null2String(rs.getString("name"))); + seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sum"))) .name(name).color(colorList.get(index)).build()); nameSet.add(name); } - TreeSet legendDataFirst = new TreeSet<>(); + LinkedList legendDataFirst = new LinkedList<>(); if (nameSet.size() > 2) { - treeSetSplitExample(legendDataFirst,nameSet); + legendDataFirst = treeSetSplitExample(nameSet); } return OptionVO.builder() @@ -234,7 +242,7 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getSurname() { RecordSet rs = new RecordSet(); - TreeSet seriesData = new TreeSet<>(); + LinkedList seriesData = new LinkedList<>(); List surnameList = new ArrayList<>(); rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " + @@ -252,10 +260,12 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo int percentage = statisticsList.stream().mapToInt(Integer::intValue).sum(); List newList = statisticsList.stream() - .map(num -> num / percentage) + .map(num -> (num * 100 ) / percentage ) .collect(Collectors.toList()); - newList.stream().map(count -> seriesData.add(SeriesParam.builder().value(count).build())); + newList.forEach(count -> { + seriesData.add(SeriesParam.builder().value(count).build()); + }); return OptionVO.builder() .titleText("司龄统计") @@ -266,8 +276,8 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getAgeAndSex() { RecordSet rs = new RecordSet(); - TreeSet barSeriesData = new TreeSet<>(); - TreeSet barSeriesDataTwo = new TreeSet<>(); + LinkedList barSeriesData = new LinkedList<>(); + LinkedList barSeriesDataTwo = new LinkedList<>(); List ageArr = Arrays.asList("16~20","21~25","26~30","31~35","36~40","41~45","46~50","51~55","56~60","61~65","66~70"); List birthdayListMen = new ArrayList<>(); @@ -283,14 +293,15 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo }) .collect(Collectors.toList()); - int yMax = menAge.stream().max(Integer::compare).orElse(0) + 20; + for (int i = 0; i < ageArr.size(); i++) { String[] split = ageArr.get(i).split("~"); - Integer sum = menAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).mapToInt(Integer::valueOf).sum(); - barSeriesData.add(sum); + List collect = menAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList()); + barSeriesData.add(collect.size()); } + int yMax = barSeriesData.stream().max(Integer::compare).orElse(0) + 20; List birthdayListWomen = new ArrayList<>(); rs.executeQuery("select birthday from hrmresource where status < 4 and sex is not null and sex = 1"); @@ -305,14 +316,18 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo }) .collect(Collectors.toList()); - int yMin = -(womenAge.stream().max(Integer::compare).orElse(0) + 20); + LinkedList list = new LinkedList<>(); for (int i = 0; i < ageArr.size(); i++) { String[] split = ageArr.get(i).split("~"); - Integer sum = womenAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).mapToInt(Integer::valueOf).sum(); - barSeriesDataTwo.add(sum); + List collect = womenAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList()); + barSeriesDataTwo.add(-collect.size()); + list.add(collect.size()); } + int yMin = -(list.stream().max(Integer::compare).orElse(0) + 20); + + Integer yInterval = (yMax + Math.abs(yMin)) / 6; return OptionVO.builder() @@ -327,7 +342,34 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo @Override public OptionVO getJobType() { - return null; + RecordSet rs = new RecordSet(); + LinkedList xData = new LinkedList<>(); + LinkedList barSeriesData = new LinkedList<>(); + + rs.executeQuery("select a.*,b.jobgroupname from (select g.id as jobgroupid,count(1) as sum from hrmresource h \n" + + " left join hrmjobtitles j on h.jobtitle = j.id\n" + + " left join hrmjobactivities c on j.jobactivityid = c.id\n" + + " left join hrmjobgroups g on c.jobgroupid = g.id\n" + + " where h.status < 4 and g.id is not null group by g.id) as a left join hrmjobgroups b on a.jobgroupid = b.id"); + + while (rs.next()) { + xData.add(Util.null2String(rs.getString("jobgroupname"))); + barSeriesData.add(Util.getIntValue(rs.getString("sum"))); + } + + int max = Collections.max(barSeriesData); + int ceil =(int) Math.ceil((double) max / 4); + ceil = CommonUtils.roundUpToNearestTen(ceil); + int roundedMax = CommonUtils.roundedMax(ceil, 4); + + return OptionVO.builder() + .titleText("职务类别统计") + .xData(xData) + .yMin(0) + .yMax(roundedMax) + .yInterval(ceil) + .barSeriesData(barSeriesData) + .build(); } @Override @@ -336,9 +378,9 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo RecordSet rs = new RecordSet(); String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now())); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); - TreeSet xData = new TreeSet<>(); - TreeSet barSeriesData = new TreeSet<>(); - TreeSet browser = new TreeSet<>(); + LinkedList xData = new LinkedList<>(); + LinkedList barSeriesData = new LinkedList<>(); + LinkedList browser = new LinkedList<>(); StringBuilder sql = new StringBuilder(); sql.append("select t.departmentname, t.id,CASE \n" + @@ -346,7 +388,7 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo " ELSE a.sum \n" + " END AS num from hrmdepartment t \n" + " left join (select s.departmentid,count(1) as sum from hrmstatushistory h left join hrmresource s on h.resourceid = s.id " + - " where type_n = 5 and changedate >= ? && changedate <= ? group by s.departmentid ) a\n" + + " where type_n = 5 and changedate >= ? and changedate <= ? group by s.departmentid ) a\n" + " on t.id = a.departmentid"); if(StringUtils.isNotEmpty(departmentIds)) { @@ -389,12 +431,12 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo public Map getLeaveYear(String departmentIds) { Map data = new HashMap<>(4); RecordSet rs = new RecordSet(); - TreeSet legendDataFirst = new TreeSet<>(); - TreeSet barSeriesData = new TreeSet<>(); - TreeSet barSeriesDataTwo = new TreeSet<>(); - TreeSet barSeriesDataThree = new TreeSet<>(); + LinkedList legendDataFirst = new LinkedList<>(); + LinkedList barSeriesData = new LinkedList<>(); + LinkedList barSeriesDataTwo = new LinkedList<>(); + LinkedList barSeriesDataThree = new LinkedList<>(); DepartmentComInfo comInfo = new DepartmentComInfo(); - TreeSet browser = new TreeSet<>(); + LinkedList browser = new LinkedList<>(); List deptList = new ArrayList<>(); if(StringUtils.isNotEmpty(departmentIds)) { @@ -441,6 +483,9 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo case 2: barSeriesDataThree.add(value); break; + default: + break; + } } @@ -472,19 +517,20 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo private Integer calculateLeave(Integer id,String startMonth,String endMonth) { RecordSet rs = new RecordSet(); - StringBuilder sql = new StringBuilder(); - sql.append("select t.departmentname, t.id,CASE \n" + + String sql = ("select t.departmentname, t.id,CASE \n" + " WHEN a.sum IS NULL THEN 0 \n" + " ELSE a.sum \n" + " END AS num from hrmdepartment t \n" + " left join (select s.departmentid,count(1) as sum from hrmstatushistory h left join hrmresource s on h.resourceid = s.id " + - " where type_n = 5 and changedate >= ? && changedate <= ? group by s.departmentid ) a\n" + + " where type_n = 5 and changedate >= ? and changedate <= ? group by s.departmentid ) a\n" + " on t.id = a.departmentid where t.id = ?"); - rs.executeQuery(sql.toString(),startMonth,endMonth,id); + rs.executeQuery(sql,startMonth,endMonth,id); rs.next(); return Util.getIntValue(rs.getString("num")) / countBydeptId(id,endMonth); } + + /** * 部门人数统计 * @param departmentId @@ -508,16 +554,16 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo /** * 平分legendData - * @param legendDataFirst * @param nameSet */ - private void treeSetSplitExample(TreeSet legendDataFirst,TreeSet nameSet) { + private LinkedList treeSetSplitExample(LinkedList nameSet) { int splitSize = nameSet.size() / 2; - legendDataFirst = nameSet.stream() - .collect(Collectors.partitioningBy(e -> nameSet.headSet(e).size() < splitSize, - Collectors.toCollection(TreeSet::new))) + LinkedList legendDataFirst = nameSet.stream() + .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize, + Collectors.toCollection(LinkedList::new))) .get(false); nameSet.removeAll(legendDataFirst); + return legendDataFirst; } /** diff --git a/src/com/engine/matfron/web/StatisticsPortalAction.java b/src/com/engine/matfron/web/StatisticsPortalAction.java index 65a2d4b..934e803 100644 --- a/src/com/engine/matfron/web/StatisticsPortalAction.java +++ b/src/com/engine/matfron/web/StatisticsPortalAction.java @@ -17,8 +17,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import java.util.LinkedList; import java.util.Map; -import java.util.TreeSet; + /** * @Author liang.cheng @@ -38,7 +39,7 @@ public class StatisticsPortalAction { @Produces(MediaType.APPLICATION_JSON) public String getPortalTop(@Context HttpServletRequest request, @Context HttpServletResponse response) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult>(user).run(getCommonDutyService(user) :: getPortalTop); + return new ResponseResult>(user).run(getCommonDutyService(user) :: getPortalTop); } @GET diff --git a/src/test/MainTest.java b/src/test/MainTest.java index f1a5a5b..4366487 100644 --- a/src/test/MainTest.java +++ b/src/test/MainTest.java @@ -2,6 +2,7 @@ package test; import com.engine.matfron.entity.SurnameParam; import com.engine.matfron.util.CommonDateUtil; +import emo.doors.b; import java.time.LocalDate; import java.time.YearMonth; @@ -18,16 +19,13 @@ public class MainTest { public static void main(String[] args) { - List surnameList = new ArrayList<>(); - surnameList.add(SurnameParam.builder().companyworkyear(1.72).count(8).build()); - surnameList.add(SurnameParam.builder().companyworkyear(2.19).count(18).build()); - surnameList.add(SurnameParam.builder().companyworkyear(3.12).count(9).build()); - surnameList.add(SurnameParam.builder().companyworkyear(2.80).count(8).build()); - surnameList.add(SurnameParam.builder().companyworkyear(5.72).count(6).build()); - surnameList.add(SurnameParam.builder().companyworkyear(10.72).count(28).build()); - Integer sum = surnameList.stream().filter(item -> item.getCompanyworkyear() > 10 && item.getCompanyworkyear() <= 100) - .mapToInt(SurnameParam::getCount).sum(); - System.out.println(sum); + TreeSet a = new TreeSet<>(); + a.add("和平"); + a.add("阿姨"); + a.add("测试"); + for (String string : a) { + System.out.println(string); + } } }