铭沣科技统计分析门户接口 饼图 柱状图

统计分析门户标准
Chengliang 2 years ago
parent db45ec244e
commit 3046781b4e

@ -5,7 +5,7 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.TreeSet; import java.util.LinkedList;
/** /**
* @Author liang.cheng * @Author liang.cheng
@ -22,7 +22,7 @@ public class OptionVO {
private String titleText; private String titleText;
private TreeSet<String> xData; private LinkedList<String> xData;
private Integer yMin; private Integer yMin;
@ -30,18 +30,18 @@ public class OptionVO {
private Integer yInterval; private Integer yInterval;
private TreeSet<Integer> yData; private LinkedList<Integer> yData;
private TreeSet<String> legendDataFirst; private LinkedList<String> legendDataFirst;
private TreeSet<String> legendDataTwo; private LinkedList<String> legendDataTwo;
private TreeSet<Integer> barSeriesData; private LinkedList<Integer> barSeriesData;
private TreeSet<Integer> barSeriesDataTwo; private LinkedList<Integer> barSeriesDataTwo;
private TreeSet<Integer> barSeriesDataThree; private LinkedList<Integer> barSeriesDataThree;
private TreeSet<SeriesParam> seriesData; private LinkedList<SeriesParam> seriesData;
} }

@ -3,8 +3,8 @@ package com.engine.matfron.service;
import com.engine.matfron.entity.OptionVO; import com.engine.matfron.entity.OptionVO;
import com.engine.matfron.entity.PortalTopVO; import com.engine.matfron.entity.PortalTopVO;
import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.TreeSet;
/** /**
@ -22,7 +22,7 @@ public interface StatisticsPortalService {
* @param: [] * @param: []
* @return: com.engine.matfron.entity.PortalTopVO * @return: com.engine.matfron.entity.PortalTopVO
*/ */
TreeSet<PortalTopVO> getPortalTop(); LinkedList<PortalTopVO> getPortalTop();
/** /**
* @Description: * @Description:

@ -11,6 +11,7 @@ import weaver.conn.RecordSet;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.DepartmentComInfo;
import java.text.DecimalFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Period; import java.time.Period;
import java.time.YearMonth; import java.time.YearMonth;
@ -31,9 +32,9 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public TreeSet<PortalTopVO> getPortalTop() { public LinkedList<PortalTopVO> getPortalTop() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
TreeSet<PortalTopVO> portalTopVOList = new TreeSet<>(); LinkedList<PortalTopVO> portalTopVOList = new LinkedList<>();
rs.executeQuery("select count(1) as count from hrmresource where status < 4"); rs.executeQuery("select count(1) as count from hrmresource where status < 4");
rs.next(); rs.next();
@ -46,12 +47,14 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
while (rs.next()) { while (rs.next()) {
birthdayList.add(Util.null2String(rs.getString("birthday"))); birthdayList.add(Util.null2String(rs.getString("birthday")));
} }
DecimalFormat df = new DecimalFormat("#.00");
double averageAge = birthdayList.stream() double averageAge = birthdayList.stream()
.map(CommonUtils::parseLocalDate) .map(CommonUtils::parseLocalDate)
.mapToInt(CommonUtils::calculateAge) .mapToInt(CommonUtils::calculateAge)
.average() .average()
.orElse(0); .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 startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now()));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
@ -66,29 +69,26 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getPortalDepartment() { public OptionVO getPortalDepartment() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
TreeSet<String> xData = new TreeSet<>(); LinkedList<String> xData = new LinkedList<>();
TreeSet<Integer> yData = new TreeSet<>(); LinkedList<Integer> yData = new LinkedList<>();
List<Integer> ids = new ArrayList<>(); List<Integer> 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()) { while (rs.next()) {
xData.add(Util.null2String(rs.getString("departmentname"))); xData.add(Util.null2String(rs.getString("departmentname")));
ids.add(Util.getIntValue(rs.getString("id"))); ids.add(Util.getIntValue(rs.getString("id")));
} }
List<DepartmentParam> deptList = new ArrayList<>(); List<DepartmentParam> 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()) { 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 max = Collections.max(yData);
int ceil =(int) Math.ceil((double) max / 5); int ceil =(int) Math.ceil((double) max / 5);
@ -108,16 +108,18 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getPortalSubCompany() { public OptionVO getPortalSubCompany() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
TreeSet<Integer> yData = new TreeSet<>(); LinkedList<Integer> yData = new LinkedList<>();
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now()); List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
yearMonths.forEach(yearMonth -> { yearMonths.forEach(yearMonth -> {
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth)); String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(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.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ?",endMonth);
rs.next(); if (rs.next()) {
Integer sum = Util.getIntValue(rs.getString("sum"),0); Integer sum = Util.getIntValue(rs.getString("sum"),0);
yData.add(sum); yData.add(sum);
}
}); });
int max = Collections.max(yData); int max = Collections.max(yData);
@ -137,30 +139,27 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getPortalEthnic() { public OptionVO getPortalEthnic() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9","#faf0e6","#7cfc00","#ao20f0","#9933fa"); List<String> colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9","#faf0e6","#7cfc00","#ao20f0","#9933fa","#c0ff3e","#00ced1","#ffe4c4","#cd6090");
TreeSet<SeriesParam> seriesData = new TreeSet<>(); LinkedList<SeriesParam> seriesData = new LinkedList<>();
TreeSet<String> nameSet = new TreeSet<>(); LinkedList<String> nameSet = new LinkedList<>();
rs.executeQuery("select distinct folk,count(1) as sums from hrmresource where status < 4 \n" + rs.executeQuery("select distinct folk,count(1) as sums from hrmresource where status < 4 \n" +
" and folk is not null group by folk"); " and folk is not null group by folk");
int index = 0;
while (rs.next()) { while (rs.next()) {
if (index > colorList.size()){ Random random = new Random();
index = 0; String color = colorList.get(random.nextInt(colorList.size()));
} String name = Util.null2String(rs.getString("folk"));
index++;
String name = Util.null2String(rs.getString("name"));
seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sums"))) 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); nameSet.add(name);
} }
TreeSet<String> legendDataFirst = null; LinkedList<String> legendDataFirst = null;
if (nameSet.size() > 2) { if (nameSet.size() > 2) {
int splitSize = nameSet.size() / 2; int splitSize = nameSet.size() / 2;
legendDataFirst = nameSet.stream() legendDataFirst = nameSet.stream()
.collect(Collectors.partitioningBy(e -> nameSet.headSet(e).size() < splitSize, .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize,
Collectors.toCollection(TreeSet::new))) Collectors.toCollection(LinkedList::new)))
.get(false); .get(false);
nameSet.removeAll(legendDataFirst); nameSet.removeAll(legendDataFirst);
} }
@ -176,51 +175,60 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getHomePlace() { public OptionVO getHomePlace() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#ao20f0","#8ac9e9","#697695","#83d8ae","#faf0e6","#7cfc00","#6e94f3","#9933fa"); List<String> colorList = Arrays.asList("#ao20f0","#8ac9e9","#697695","#83d8ae","#faf0e6","#7cfc00","#6e94f3","#9933fa","#c0ff3e","#00ced1","#ffe4c4","#cd6090");
TreeSet<SeriesParam> seriesData = new TreeSet<>(); LinkedList<SeriesParam> seriesData = new LinkedList<>();
TreeSet<String> legendData = new TreeSet<>(); LinkedList<String> legendData = new LinkedList<>();
rs.executeQuery("select h.locationid,l.locationname,count(1) as num from hrmresource h\n" + 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" + " 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()) { while (rs.next()) {
String locationname = Util.null2String(rs.getString("locationname")); String locationname = Util.null2String(rs.getString("locationname"));
legendData.add(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<Integer> 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 @Override
public OptionVO getEducational() { public OptionVO getEducational() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#ee8164","#f19c45","#6fcecf","#507ef7","#faf0e6","#7cfc00","#ao20f0","#9933fa"); List<String> colorList = Arrays.asList("#ee8164","#f19c45","#6fcecf","#507ef7","#faf0e6","#7cfc00","#ao20f0","#9933fa");
TreeSet<SeriesParam> seriesData = new TreeSet<>(); LinkedList<SeriesParam> seriesData = new LinkedList<>();
TreeSet<String> nameSet = new TreeSet<>(); LinkedList<String> nameSet = new LinkedList<>();
rs.executeQuery("select distinct h.educationlevel,count(1) as sum,d.name from hrmresource h\n" + 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" + "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; int index = 0;
while (rs.next()) { while (rs.next()) {
if (index > colorList.size()){ if (index > colorList.size()){
index = 0; index = 0;
} }
index++; index++;
String name = Util.null2String(rs.getString("name")); String name = Util.formatMultiLang (Util.null2String(rs.getString("name")));
if (name.contains("~")) {
name = chineseSubstringExample(name);
}
seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sum"))) seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sum")))
.name(name).color(colorList.get(index)).build()); .name(name).color(colorList.get(index)).build());
nameSet.add(name); nameSet.add(name);
} }
TreeSet<String> legendDataFirst = new TreeSet<>(); LinkedList<String> legendDataFirst = new LinkedList<>();
if (nameSet.size() > 2) { if (nameSet.size() > 2) {
treeSetSplitExample(legendDataFirst,nameSet); legendDataFirst = treeSetSplitExample(nameSet);
} }
return OptionVO.builder() return OptionVO.builder()
@ -234,7 +242,7 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getSurname() { public OptionVO getSurname() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
TreeSet<SeriesParam> seriesData = new TreeSet<>(); LinkedList<SeriesParam> seriesData = new LinkedList<>();
List<SurnameParam> surnameList = new ArrayList<>(); List<SurnameParam> surnameList = new ArrayList<>();
rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " + 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(); int percentage = statisticsList.stream().mapToInt(Integer::intValue).sum();
List<Integer> newList = statisticsList.stream() List<Integer> newList = statisticsList.stream()
.map(num -> num / percentage) .map(num -> (num * 100 ) / percentage )
.collect(Collectors.toList()); .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() return OptionVO.builder()
.titleText("司龄统计") .titleText("司龄统计")
@ -266,8 +276,8 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getAgeAndSex() { public OptionVO getAgeAndSex() {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
TreeSet<Integer> barSeriesData = new TreeSet<>(); LinkedList<Integer> barSeriesData = new LinkedList<>();
TreeSet<Integer> barSeriesDataTwo = new TreeSet<>(); LinkedList<Integer> barSeriesDataTwo = new LinkedList<>();
List<String> 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<String> 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<String> birthdayListMen = new ArrayList<>(); List<String> birthdayListMen = new ArrayList<>();
@ -283,14 +293,15 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
int yMax = menAge.stream().max(Integer::compare).orElse(0) + 20;
for (int i = 0; i < ageArr.size(); i++) { for (int i = 0; i < ageArr.size(); i++) {
String[] split = ageArr.get(i).split("~"); 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(); List<Integer> collect = menAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList());
barSeriesData.add(sum); barSeriesData.add(collect.size());
} }
int yMax = barSeriesData.stream().max(Integer::compare).orElse(0) + 20;
List<String> birthdayListWomen = new ArrayList<>(); List<String> birthdayListWomen = new ArrayList<>();
rs.executeQuery("select birthday from hrmresource where status < 4 and sex is not null and sex = 1"); 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()); .collect(Collectors.toList());
int yMin = -(womenAge.stream().max(Integer::compare).orElse(0) + 20);
LinkedList<Integer> list = new LinkedList<>();
for (int i = 0; i < ageArr.size(); i++) { for (int i = 0; i < ageArr.size(); i++) {
String[] split = ageArr.get(i).split("~"); 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(); List<Integer> collect = womenAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList());
barSeriesDataTwo.add(sum); 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; Integer yInterval = (yMax + Math.abs(yMin)) / 6;
return OptionVO.builder() return OptionVO.builder()
@ -327,7 +342,34 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override @Override
public OptionVO getJobType() { public OptionVO getJobType() {
return null; RecordSet rs = new RecordSet();
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> 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 @Override
@ -336,9 +378,9 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now())); String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now()));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
TreeSet<String> xData = new TreeSet<>(); LinkedList<String> xData = new LinkedList<>();
TreeSet<Integer> barSeriesData = new TreeSet<>(); LinkedList<Integer> barSeriesData = new LinkedList<>();
TreeSet<BrowserParam> browser = new TreeSet<>(); LinkedList<BrowserParam> browser = new LinkedList<>();
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.append("select t.departmentname, t.id,CASE \n" + sql.append("select t.departmentname, t.id,CASE \n" +
@ -346,7 +388,7 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
" ELSE a.sum \n" + " ELSE a.sum \n" +
" END AS num from hrmdepartment t \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 " + " 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"); " on t.id = a.departmentid");
if(StringUtils.isNotEmpty(departmentIds)) { if(StringUtils.isNotEmpty(departmentIds)) {
@ -389,12 +431,12 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
public Map<String,Object> getLeaveYear(String departmentIds) { public Map<String,Object> getLeaveYear(String departmentIds) {
Map<String,Object> data = new HashMap<>(4); Map<String,Object> data = new HashMap<>(4);
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
TreeSet<String> legendDataFirst = new TreeSet<>(); LinkedList<String> legendDataFirst = new LinkedList<>();
TreeSet<Integer> barSeriesData = new TreeSet<>(); LinkedList<Integer> barSeriesData = new LinkedList<>();
TreeSet<Integer> barSeriesDataTwo = new TreeSet<>(); LinkedList<Integer> barSeriesDataTwo = new LinkedList<>();
TreeSet<Integer> barSeriesDataThree = new TreeSet<>(); LinkedList<Integer> barSeriesDataThree = new LinkedList<>();
DepartmentComInfo comInfo = new DepartmentComInfo(); DepartmentComInfo comInfo = new DepartmentComInfo();
TreeSet<BrowserParam> browser = new TreeSet<>(); LinkedList<BrowserParam> browser = new LinkedList<>();
List<Integer> deptList = new ArrayList<>(); List<Integer> deptList = new ArrayList<>();
if(StringUtils.isNotEmpty(departmentIds)) { if(StringUtils.isNotEmpty(departmentIds)) {
@ -441,6 +483,9 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
case 2: case 2:
barSeriesDataThree.add(value); barSeriesDataThree.add(value);
break; break;
default:
break;
} }
} }
@ -472,19 +517,20 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
private Integer calculateLeave(Integer id,String startMonth,String endMonth) { private Integer calculateLeave(Integer id,String startMonth,String endMonth) {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
StringBuilder sql = new StringBuilder(); String sql = ("select t.departmentname, t.id,CASE \n" +
sql.append("select t.departmentname, t.id,CASE \n" +
" WHEN a.sum IS NULL THEN 0 \n" + " WHEN a.sum IS NULL THEN 0 \n" +
" ELSE a.sum \n" + " ELSE a.sum \n" +
" END AS num from hrmdepartment t \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 " + " 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 = ?"); " on t.id = a.departmentid where t.id = ?");
rs.executeQuery(sql.toString(),startMonth,endMonth,id); rs.executeQuery(sql,startMonth,endMonth,id);
rs.next(); rs.next();
return Util.getIntValue(rs.getString("num")) / countBydeptId(id,endMonth); return Util.getIntValue(rs.getString("num")) / countBydeptId(id,endMonth);
} }
/** /**
* *
* @param departmentId * @param departmentId
@ -508,16 +554,16 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
/** /**
* legendData * legendData
* @param legendDataFirst
* @param nameSet * @param nameSet
*/ */
private void treeSetSplitExample(TreeSet<String> legendDataFirst,TreeSet<String> nameSet) { private LinkedList<String> treeSetSplitExample(LinkedList<String> nameSet) {
int splitSize = nameSet.size() / 2; int splitSize = nameSet.size() / 2;
legendDataFirst = nameSet.stream() LinkedList<String> legendDataFirst = nameSet.stream()
.collect(Collectors.partitioningBy(e -> nameSet.headSet(e).size() < splitSize, .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize,
Collectors.toCollection(TreeSet::new))) Collectors.toCollection(LinkedList::new)))
.get(false); .get(false);
nameSet.removeAll(legendDataFirst); nameSet.removeAll(legendDataFirst);
return legendDataFirst;
} }
/** /**

@ -17,8 +17,9 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.TreeSet;
/** /**
* @Author liang.cheng * @Author liang.cheng
@ -38,7 +39,7 @@ public class StatisticsPortalAction {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getPortalTop(@Context HttpServletRequest request, @Context HttpServletResponse response) { public String getPortalTop(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, TreeSet<PortalTopVO>>(user).run(getCommonDutyService(user) :: getPortalTop); return new ResponseResult<String, LinkedList<PortalTopVO>>(user).run(getCommonDutyService(user) :: getPortalTop);
} }
@GET @GET

@ -2,6 +2,7 @@ package test;
import com.engine.matfron.entity.SurnameParam; import com.engine.matfron.entity.SurnameParam;
import com.engine.matfron.util.CommonDateUtil; import com.engine.matfron.util.CommonDateUtil;
import emo.doors.b;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.YearMonth; import java.time.YearMonth;
@ -18,16 +19,13 @@ public class MainTest {
public static void main(String[] args) { public static void main(String[] args) {
List<SurnameParam> surnameList = new ArrayList<>(); TreeSet<String> a = new TreeSet<>();
surnameList.add(SurnameParam.builder().companyworkyear(1.72).count(8).build()); a.add("和平");
surnameList.add(SurnameParam.builder().companyworkyear(2.19).count(18).build()); a.add("阿姨");
surnameList.add(SurnameParam.builder().companyworkyear(3.12).count(9).build()); a.add("测试");
surnameList.add(SurnameParam.builder().companyworkyear(2.80).count(8).build()); for (String string : a) {
surnameList.add(SurnameParam.builder().companyworkyear(5.72).count(6).build()); System.out.println(string);
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);
} }
} }

Loading…
Cancel
Save