|
|
|
@ -1,10 +1,7 @@
|
|
|
|
|
package com.engine.matfron.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.matfron.entity.DepartmentParam;
|
|
|
|
|
import com.engine.matfron.entity.OptionVO;
|
|
|
|
|
import com.engine.matfron.entity.PortalTopVO;
|
|
|
|
|
import com.engine.matfron.entity.SeriesParam;
|
|
|
|
|
import com.engine.matfron.entity.*;
|
|
|
|
|
import com.engine.matfron.service.StatisticsPortalService;
|
|
|
|
|
import com.engine.matfron.util.CommonDateUtil;
|
|
|
|
|
import com.engine.matfron.util.CommonUtils;
|
|
|
|
@ -13,8 +10,12 @@ import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.Period;
|
|
|
|
|
import java.time.YearMonth;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -134,17 +135,233 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
|
|
|
|
|
@Override
|
|
|
|
|
public OptionVO getPortalEthnic() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
List<String> colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9");
|
|
|
|
|
List<String> colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9","#faf0e6","#7cfc00","#ao20f0","#9933fa");
|
|
|
|
|
TreeSet<SeriesParam> seriesData = new TreeSet<>();
|
|
|
|
|
TreeSet<String> nameSet = new TreeSet<>();
|
|
|
|
|
|
|
|
|
|
rs.executeQuery("select distinct folk,count(1) as count 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");
|
|
|
|
|
int index = 0;
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
seriesData.add(SeriesParam.builder().build());
|
|
|
|
|
if (index > colorList.size()){
|
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
String name = Util.null2String(rs.getString("name"));
|
|
|
|
|
seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sums")))
|
|
|
|
|
.name(name).color(colorList.get(index)).build());
|
|
|
|
|
nameSet.add(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TreeSet<String> 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)))
|
|
|
|
|
.get(false);
|
|
|
|
|
nameSet.removeAll(legendDataFirst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OptionVO.builder()
|
|
|
|
|
.titleText("民族分析")
|
|
|
|
|
.legendDataFirst(legendDataFirst)
|
|
|
|
|
.legendDataTwo(nameSet)
|
|
|
|
|
.seriesData(seriesData)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OptionVO getEducational() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
List<String> colorList = Arrays.asList("#ee8164","#f19c45","#6fcecf","#507ef7","#faf0e6","#7cfc00","#ao20f0","#9933fa");
|
|
|
|
|
TreeSet<SeriesParam> seriesData = new TreeSet<>();
|
|
|
|
|
TreeSet<String> nameSet = new TreeSet<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
seriesData.add(SeriesParam.builder().value(Util.getIntValue(rs.getString("sum")))
|
|
|
|
|
.name(name).color(colorList.get(index)).build());
|
|
|
|
|
nameSet.add(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TreeSet<String> legendDataFirst = new TreeSet<>();
|
|
|
|
|
|
|
|
|
|
if (nameSet.size() > 2) {
|
|
|
|
|
treeSetSplitExample(legendDataFirst,nameSet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OptionVO.builder()
|
|
|
|
|
.titleText("学历分析")
|
|
|
|
|
.legendDataFirst(legendDataFirst)
|
|
|
|
|
.legendDataTwo(nameSet)
|
|
|
|
|
.seriesData(seriesData)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OptionVO getSurname() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
TreeSet<SeriesParam> seriesData = new TreeSet<>();
|
|
|
|
|
|
|
|
|
|
List<SurnameParam> surnameList = new ArrayList<>();
|
|
|
|
|
rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " +
|
|
|
|
|
" and companyworkyear is not null group by companyworkyear ");
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
surnameList.add(SurnameParam.builder().companyworkyear(Util.getDoubleValue(rs.getString("companyworkyear"))).count(Util.getIntValue(rs.getString("sum"))).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Integer> statisticsArr = Arrays.asList(0,1,3,5,10,100);
|
|
|
|
|
List<Integer> statisticsList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
|
Integer count = statisticsSurname(statisticsArr.get(i), statisticsArr.get(i+1), surnameList);
|
|
|
|
|
statisticsList.add(count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int percentage = statisticsList.stream().mapToInt(Integer::intValue).sum();
|
|
|
|
|
List<Integer> newList = statisticsList.stream()
|
|
|
|
|
.map(num -> num / percentage)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
newList.stream().map(count -> seriesData.add(SeriesParam.builder().value(count).build()));
|
|
|
|
|
|
|
|
|
|
return OptionVO.builder()
|
|
|
|
|
.titleText("司龄统计")
|
|
|
|
|
.seriesData(seriesData)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OptionVO getAgeAndSex() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
TreeSet<Integer> barSeriesData = new TreeSet<>();
|
|
|
|
|
TreeSet<Integer> barSeriesDataTwo = new TreeSet<>();
|
|
|
|
|
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<>();
|
|
|
|
|
rs.executeQuery("select birthday from hrmresource where status < 4 and sex is not null and sex = 0");
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
birthdayListMen.add(Util.null2String(rs.getString("birthday")));
|
|
|
|
|
}
|
|
|
|
|
List<Integer> menAge = birthdayListMen.stream()
|
|
|
|
|
.map(birthday -> {
|
|
|
|
|
LocalDate birthdate = LocalDate.parse(birthday);
|
|
|
|
|
LocalDate now = LocalDate.now();
|
|
|
|
|
return Period.between(birthdate, now).getYears();
|
|
|
|
|
})
|
|
|
|
|
.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<String> birthdayListWomen = new ArrayList<>();
|
|
|
|
|
rs.executeQuery("select birthday from hrmresource where status < 4 and sex is not null and sex = 1");
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
birthdayListWomen.add(Util.null2String(rs.getString("birthday")));
|
|
|
|
|
}
|
|
|
|
|
List<Integer> womenAge = birthdayListWomen.stream()
|
|
|
|
|
.map(birthday -> {
|
|
|
|
|
LocalDate birthdate = LocalDate.parse(birthday);
|
|
|
|
|
LocalDate now = LocalDate.now();
|
|
|
|
|
return Period.between(birthdate, now).getYears();
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
int yMin = -(womenAge.stream().max(Integer::compare).orElse(0) + 20);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Integer yInterval = (yMax + Math.abs(yMin)) / 6;
|
|
|
|
|
|
|
|
|
|
return OptionVO.builder()
|
|
|
|
|
.titleText("年龄与性别分析")
|
|
|
|
|
.yMin(yMin)
|
|
|
|
|
.yMax(yMax)
|
|
|
|
|
.yInterval(yInterval)
|
|
|
|
|
.barSeriesData(barSeriesData)
|
|
|
|
|
.barSeriesDataTwo(barSeriesDataTwo)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OptionVO getJobType() {
|
|
|
|
|
// todo 职务岗位太多
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OptionVO getLeaveMonth() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据范围统计司龄的个数
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private Integer statisticsSurname(Integer min,Integer max,List<SurnameParam> surnameList) {
|
|
|
|
|
return surnameList.stream().filter(item -> item.getCompanyworkyear() > min && item.getCompanyworkyear() <= max)
|
|
|
|
|
.mapToInt(SurnameParam::getCount).sum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 平分legendData
|
|
|
|
|
* @param legendDataFirst
|
|
|
|
|
* @param nameSet
|
|
|
|
|
*/
|
|
|
|
|
private void treeSetSplitExample(TreeSet<String> legendDataFirst,TreeSet<String> nameSet) {
|
|
|
|
|
int splitSize = nameSet.size() / 2;
|
|
|
|
|
legendDataFirst = nameSet.stream()
|
|
|
|
|
.collect(Collectors.partitioningBy(e -> nameSet.headSet(e).size() < splitSize,
|
|
|
|
|
Collectors.toCollection(TreeSet::new)))
|
|
|
|
|
.get(false);
|
|
|
|
|
nameSet.removeAll(legendDataFirst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 多语言匹配中文
|
|
|
|
|
* @param input
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String chineseSubstringExample(String input) {
|
|
|
|
|
|
|
|
|
|
String r = "7.*`~`8";
|
|
|
|
|
Pattern pattern1 = Pattern.compile(r);
|
|
|
|
|
Matcher matcher = pattern1.matcher(input);
|
|
|
|
|
|
|
|
|
|
while (matcher.find()) {
|
|
|
|
|
input = matcher.group(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用正则表达式匹配中文
|
|
|
|
|
String pattern = "[\u4E00-\u9FA5\u8FBD-\u9FBB\uFA0E-\uFA29]+";
|
|
|
|
|
Pattern s = Pattern.compile(pattern);
|
|
|
|
|
Matcher m = s.matcher(input);
|
|
|
|
|
while (m.find()) {
|
|
|
|
|
input = m.group(0);
|
|
|
|
|
}
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|