forked from chenwei/weaver-matfron
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.7 KiB
Plaintext
73 lines
2.7 KiB
Plaintext
<%@ page import="weaver.general.*" %>
|
|
<%@page import="weaver.conn.RecordSet"%>
|
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
|
<%@ page import="java.util.*" %>
|
|
<%@ page import="java.util.stream.Collectors" %>
|
|
<%@ page import="com.engine.matfron.entity.OptionVO" %>
|
|
<%@ page import="com.engine.matfron.entity.SeriesParam" %>
|
|
<%@ page import="com.engine.matfron.entity.SurnameParam" %>
|
|
<%@ page import="java.text.DecimalFormat" %>
|
|
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
|
|
<jsp:useBean id="bb" class="weaver.general.BaseBean" scope="page" />
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
|
|
|
<%
|
|
JSONObject jsonObject = new JSONObject();
|
|
OptionVO OptionVO = getSurname();
|
|
jsonObject.put("data",OptionVO);
|
|
|
|
%>
|
|
<%=jsonObject.toString() %>
|
|
|
|
<%!
|
|
|
|
public OptionVO getSurname() {
|
|
|
|
DecimalFormat df = new DecimalFormat("#.00");
|
|
|
|
RecordSet rs = new RecordSet();
|
|
LinkedList<SeriesParam> seriesData = new LinkedList<>();
|
|
String where = " and (belongto is null or belongto = -1 ) ";
|
|
|
|
List<SurnameParam> surnameList = new ArrayList<>();
|
|
rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " + where +
|
|
" 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<Double> statisticsList = new ArrayList<>();
|
|
for (int i = 0; i < 5; i++) {
|
|
double count = statisticsSurname(statisticsArr.get(i), statisticsArr.get(i+1), surnameList);
|
|
statisticsList.add(count);
|
|
}
|
|
|
|
double percentage = statisticsList.stream().mapToDouble(Double::doubleValue).sum();
|
|
List<Double> newList = statisticsList.stream()
|
|
.map(num -> Double.valueOf (df.format((num * 100 ) / percentage)))
|
|
.collect(Collectors.toList());
|
|
|
|
newList.forEach(count -> seriesData.add(SeriesParam.builder().value(count).build()));
|
|
|
|
return OptionVO.builder()
|
|
.titleText("司龄统计")
|
|
.seriesData(seriesData)
|
|
.build();
|
|
}
|
|
|
|
|
|
/**
|
|
* 根据范围统计司龄的个数
|
|
* @return
|
|
*/
|
|
private Double statisticsSurname(Integer min,Integer max,List<SurnameParam> surnameList) {
|
|
return surnameList.stream().filter(item -> item.getCompanyworkyear() > min && item.getCompanyworkyear() <= max)
|
|
.mapToDouble(SurnameParam::getCount).sum();
|
|
}
|
|
|
|
%>
|
|
|
|
|
|
|