forked from chenwei/weaver-matfron
#matfron-2# 统计门户的元素优化
parent
201b0d40e4
commit
21056c999d
@ -0,0 +1,101 @@
|
|||||||
|
<%@ page import="weaver.general.*" %>
|
||||||
|
<%@page import="weaver.conn.RecordSet"%>
|
||||||
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="com.engine.matfron.util.CommonUtils" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.DepartmentParam" %>
|
||||||
|
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.OptionVO" %>
|
||||||
|
<%@ page import="com.fasterxml.jackson.databind.ObjectMapper" %>
|
||||||
|
<%@ page import="com.fasterxml.jackson.core.JsonProcessingException" %>
|
||||||
|
<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 = getPortalDepartment();
|
||||||
|
jsonObject.put("data",optionVO);
|
||||||
|
|
||||||
|
%>
|
||||||
|
<%=jsonObject.toJSONString() %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
|
||||||
|
public OptionVO getPortalDepartment() {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
LinkedList<String> xData = new LinkedList<>();
|
||||||
|
LinkedList<Integer> yData = new LinkedList<>();
|
||||||
|
String where = " and (belongto is null or belongto = -1 ) ";
|
||||||
|
List<Integer> ids = new ArrayList<>();
|
||||||
|
rs.executeQuery(" select id,departmentname from hrmdepartment where supdepid = 0 and (canceled = 0 or canceled is null) and subcompanyid1 = 62 ");
|
||||||
|
while (rs.next()) {
|
||||||
|
xData.add(Util.null2String(rs.getString("departmentname")));
|
||||||
|
ids.add(Util.getIntValue(rs.getString("id")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(int deptid : ids){
|
||||||
|
if(StringUtils.isNotBlank(deptid+"")){
|
||||||
|
String deptids = "" ;
|
||||||
|
String sql =" with tem_table(department_id,department_name,supdep_id,curlevel,canceled) as (\n" +
|
||||||
|
" select id,departmentname,supdepid, 1 as level,canceled\n" +
|
||||||
|
" from HrmDepartment where id = " + deptid +
|
||||||
|
" union all \n" +
|
||||||
|
" select a.id,a.departmentname,a.supdepid, b.curlevel+1 ,a.canceled\n" +
|
||||||
|
" from HrmDepartment a \n" +
|
||||||
|
" inner join tem_table b on ( b.department_id = a.supdepid )\n" +
|
||||||
|
" )\n" +
|
||||||
|
" select * from tem_table where isnull(canceled,0) !=1 " ;
|
||||||
|
rs.executeQuery(sql);
|
||||||
|
while (rs.next()){
|
||||||
|
String depid = Util.null2String(rs.getString("department_id"));
|
||||||
|
deptids += StringUtils.isBlank(deptids) ? depid : ","+depid ;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DepartmentParam> deptList = new ArrayList<>();
|
||||||
|
sql = " SELECT count(id) as num FROM hrmresource where status < 4 and departmentid in("+deptids+") "+where ;
|
||||||
|
rs.executeQuery(sql);
|
||||||
|
if (rs.next()) {
|
||||||
|
int num = Util.getIntValue(rs.getString("num"));
|
||||||
|
yData.add(num);
|
||||||
|
deptList.add(DepartmentParam.builder().departmentId(deptid).count(num).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int max = Collections.max(yData);
|
||||||
|
int ceil =(int) Math.ceil((double) max / 5);
|
||||||
|
ceil = CommonUtils.roundUpToNearestTen(ceil);
|
||||||
|
int roundedMax = CommonUtils.roundedMax(ceil, 5);
|
||||||
|
|
||||||
|
return OptionVO.builder()
|
||||||
|
.titleText("一级部门人数统计")
|
||||||
|
.xData(xData)
|
||||||
|
.yMin(0)
|
||||||
|
.yMax(roundedMax)
|
||||||
|
.yInterval(ceil)
|
||||||
|
.yData(yData)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static String getJsonString(Object apidatas) {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
return mapper.writeValueAsString(apidatas);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
|||||||
|
<%@ page import="weaver.general.*" %>
|
||||||
|
<%@page import="weaver.conn.RecordSet"%>
|
||||||
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="com.engine.matfron.util.CommonUtils" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.DepartmentParam" %>
|
||||||
|
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.OptionVO" %>
|
||||||
|
<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" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
LinkedList<String> xData = new LinkedList<>();
|
||||||
|
LinkedList<Integer> yData = new LinkedList<>();
|
||||||
|
String where = " and (belongto is null or belongto = -1 ) ";
|
||||||
|
List<Integer> ids = new ArrayList<>();
|
||||||
|
rs.executeQuery(" select id,departmentname from hrmdepartment where supdepid = 0 and (canceled = 0 or canceled is null) and subcompanyid1 = 62 ");
|
||||||
|
while (rs.next()) {
|
||||||
|
xData.add(Util.null2String(rs.getString("departmentname")));
|
||||||
|
ids.add(Util.getIntValue(rs.getString("id")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(int deptid : ids){
|
||||||
|
out.println("deptid:"+deptid+"</br>");
|
||||||
|
if(StringUtils.isNotBlank(deptid+"")){
|
||||||
|
String deptids = "" ;
|
||||||
|
String sql =" with tem_table(department_id,department_name,supdep_id,curlevel,canceled) as (\n" +
|
||||||
|
" select id,departmentname,supdepid, 1 as level,canceled\n" +
|
||||||
|
" from HrmDepartment where id = " + deptid +
|
||||||
|
" union all \n" +
|
||||||
|
" select a.id,a.departmentname,a.supdepid, b.curlevel+1 ,a.canceled\n" +
|
||||||
|
" from HrmDepartment a \n" +
|
||||||
|
" inner join tem_table b on ( b.department_id = a.supdepid )\n" +
|
||||||
|
" )\n" +
|
||||||
|
" select * from tem_table where isnull(canceled,0) !=1 " ;
|
||||||
|
|
||||||
|
out.println("sql:"+sql+"</br>");
|
||||||
|
|
||||||
|
rs.executeQuery(sql);
|
||||||
|
while (rs.next()){
|
||||||
|
String depid = Util.null2String(rs.getString("department_id"));
|
||||||
|
deptids += StringUtils.isBlank(deptids) ? depid : ","+depid ;
|
||||||
|
}
|
||||||
|
out.println("deptids:"+deptids+"</br>");
|
||||||
|
List<DepartmentParam> deptList = new ArrayList<>();
|
||||||
|
sql = " SELECT count(id) as num FROM hrmresource where status < 4 and departmentid in("+deptids+") "+where ;
|
||||||
|
rs.executeQuery(sql);
|
||||||
|
if (rs.next()) {
|
||||||
|
int num = Util.getIntValue(rs.getString("num"));
|
||||||
|
out.println("num:"+num+"</br>");
|
||||||
|
yData.add(num);
|
||||||
|
deptList.add(DepartmentParam.builder().departmentId(deptid).count(num).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int max = Collections.max(yData);
|
||||||
|
int ceil =(int) Math.ceil((double) max / 5);
|
||||||
|
ceil = CommonUtils.roundUpToNearestTen(ceil);
|
||||||
|
int roundedMax = CommonUtils.roundedMax(ceil, 5);
|
||||||
|
|
||||||
|
out.println(OptionVO.builder()
|
||||||
|
.titleText("一级部门人数统计")
|
||||||
|
.xData(xData)
|
||||||
|
.yMin(0)
|
||||||
|
.yMax(roundedMax)
|
||||||
|
.yInterval(ceil)
|
||||||
|
.yData(yData)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,92 @@
|
|||||||
|
<%@ page import="weaver.general.*" %>
|
||||||
|
<%@page import="weaver.conn.RecordSet"%>
|
||||||
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.OptionVO" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.SeriesParam" %>
|
||||||
|
<%@ page import="java.util.stream.Collectors" %>
|
||||||
|
<%@ 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 = getPortalEducational();
|
||||||
|
jsonObject.put("data",optionVO);
|
||||||
|
|
||||||
|
%>
|
||||||
|
<%=jsonObject.toString() %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
|
||||||
|
public OptionVO getPortalEducational() {
|
||||||
|
|
||||||
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
List<String> colorList = Arrays.asList("#faf0e6","#7cfc00","#ee8164","#9933fa","#f19c45","#6fcecf","#507ef7","#ao20f0");
|
||||||
|
LinkedList<SeriesParam> seriesData = new LinkedList<>();
|
||||||
|
LinkedList<String> nameSet = new LinkedList<>();
|
||||||
|
|
||||||
|
String sql =" select t.xl,d.name,count(1) as sum " +
|
||||||
|
" from uf_jypxjl t\n" +
|
||||||
|
" inner join hrmresource h on h.workcode = t.ygbh\n" +
|
||||||
|
" left join hrmeducationlevel d on t.xl = d.id \n" +
|
||||||
|
" where t.xl is not null \n" +
|
||||||
|
" and h.status in(0,1,2,3)\n" +
|
||||||
|
" and (h.belongto is null or h.belongto = -1 )\n" +
|
||||||
|
" group by t.xl,d.name " +
|
||||||
|
" order by t.xl desc " ;
|
||||||
|
|
||||||
|
rs.executeQuery(sql);
|
||||||
|
int index = 0;
|
||||||
|
while (rs.next()) {
|
||||||
|
if (index > colorList.size()){
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
String name = Util.formatMultiLang (Util.null2String(rs.getString("name")));
|
||||||
|
|
||||||
|
seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sum"))).name(name).color(colorList.get(index)).build());
|
||||||
|
nameSet.add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum();
|
||||||
|
seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage))));
|
||||||
|
|
||||||
|
// LinkedList<String> legendDataFirst = new LinkedList<>();
|
||||||
|
// if (nameSet.size() > 2) {
|
||||||
|
// legendDataFirst = treeSetSplitExample(nameSet);
|
||||||
|
// }
|
||||||
|
|
||||||
|
return OptionVO.builder()
|
||||||
|
.titleText("学历分析")
|
||||||
|
.legendDataFirst(nameSet)
|
||||||
|
// .legendDataTwo(nameSet)
|
||||||
|
.seriesData(seriesData)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
<%!
|
||||||
|
/**
|
||||||
|
* 平分legendData
|
||||||
|
* @param nameSet
|
||||||
|
*/
|
||||||
|
private LinkedList<String> treeSetSplitExample(LinkedList<String> nameSet) {
|
||||||
|
int splitSize = nameSet.size() / 2;
|
||||||
|
LinkedList<String> legendDataFirst = nameSet.stream()
|
||||||
|
.collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize,
|
||||||
|
Collectors.toCollection(LinkedList::new)))
|
||||||
|
.get(false);
|
||||||
|
nameSet.removeAll(legendDataFirst);
|
||||||
|
return legendDataFirst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
|||||||
|
<%@ page import="weaver.general.*" %>
|
||||||
|
<%@page import="weaver.conn.RecordSet"%>
|
||||||
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="com.engine.matfron.util.CommonUtils" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.OptionVO" %>
|
||||||
|
<%@ page import="java.time.YearMonth" %>
|
||||||
|
<%@ page import="com.engine.matfron.util.CommonDateUtil" %>
|
||||||
|
<%@ page import="java.time.LocalDate" %>
|
||||||
|
<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 = getPortalSubCompany();
|
||||||
|
jsonObject.put("data",optionVO);
|
||||||
|
jsonObject.put("status",true);
|
||||||
|
|
||||||
|
%>
|
||||||
|
<%=jsonObject.toJSONString() %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
|
||||||
|
public OptionVO getPortalSubCompany() {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
LinkedList<Integer> yData = new LinkedList<>();
|
||||||
|
String where = " and (belongto is null or belongto = -1 ) ";
|
||||||
|
|
||||||
|
List<YearMonth> 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 <= ?" + where ,endMonth);
|
||||||
|
if (rs.next()) {
|
||||||
|
Integer sum = Util.getIntValue(rs.getString("sum"),0);
|
||||||
|
yData.add(sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
int max = Collections.max(yData);
|
||||||
|
int ceil =(int) Math.ceil((double) max / 5);
|
||||||
|
ceil = CommonUtils.roundUpToNearestTen(ceil);
|
||||||
|
int roundedMax = CommonUtils.roundedMax(ceil, 5);
|
||||||
|
|
||||||
|
return OptionVO.builder()
|
||||||
|
.titleText("各月份分部总人数")
|
||||||
|
.yMin(0)
|
||||||
|
.yMax(roundedMax)
|
||||||
|
.yInterval(ceil)
|
||||||
|
.yData(yData)
|
||||||
|
.legendDataFirst(null)
|
||||||
|
.legendDataTwo(null)
|
||||||
|
.barSeriesData(null)
|
||||||
|
.barSeriesDataTwo(null)
|
||||||
|
.barSeriesDataThree(null)
|
||||||
|
.seriesData(null)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
|||||||
|
<%@ 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="java.time.LocalDate" %>
|
||||||
|
<%@ page import="java.time.Period" %>
|
||||||
|
<%@ page import="com.engine.matfron.util.CommonUtils" %>
|
||||||
|
<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 = getAgeAndSex();
|
||||||
|
jsonObject.put("data",OptionVO);
|
||||||
|
|
||||||
|
%>
|
||||||
|
<%=jsonObject.toString() %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
|
||||||
|
public OptionVO getAgeAndSex() {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
LinkedList<Integer> barSeriesData = new LinkedList<>();
|
||||||
|
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");
|
||||||
|
String where = " and (belongto is null or belongto = -1 ) ";
|
||||||
|
|
||||||
|
List<String> birthdayListMen = new ArrayList<>();
|
||||||
|
rs.executeQuery("select birthday from hrmresource where status < 4 "+where+" and sex is not null and birthday is not null and birthday <> '' 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());
|
||||||
|
for (int i = 0; i < ageArr.size(); i++) {
|
||||||
|
String[] split = ageArr.get(i).split("~");
|
||||||
|
List<Integer> 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);
|
||||||
|
|
||||||
|
List<String> birthdayListWomen = new ArrayList<>();
|
||||||
|
rs.executeQuery("select birthday from hrmresource where status < 4 "+where+" and sex is not null and birthday 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());
|
||||||
|
|
||||||
|
LinkedList<Integer> list = new LinkedList<>();
|
||||||
|
for (int i = 0; i < ageArr.size(); i++) {
|
||||||
|
String[] split = ageArr.get(i).split("~");
|
||||||
|
List<Integer> 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));
|
||||||
|
int sum = yMax > Math.abs(yMin) ? yMax : yMin ;
|
||||||
|
|
||||||
|
int divisor = sum % 6;
|
||||||
|
sum = sum + (6 - divisor) + 12;
|
||||||
|
int ceil =(int) Math.ceil((double) sum / 3);
|
||||||
|
int roundedMax = CommonUtils.roundedMax(ceil, 6);
|
||||||
|
|
||||||
|
return OptionVO.builder()
|
||||||
|
.titleText("年龄与性别分析")
|
||||||
|
.yMin(-roundedMax)
|
||||||
|
.yMax(roundedMax)
|
||||||
|
.yInterval(ceil)
|
||||||
|
.barSeriesData(barSeriesData)
|
||||||
|
.barSeriesDataTwo(barSeriesDataTwo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
|||||||
|
<%@ page import="weaver.general.*" %>
|
||||||
|
<%@page import="weaver.conn.RecordSet"%>
|
||||||
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="com.engine.matfron.entity.OptionVO" %>
|
||||||
|
<%@ page import="com.engine.matfron.util.CommonUtils" %>
|
||||||
|
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||||
|
<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 = getJobType();
|
||||||
|
jsonObject.put("data",OptionVO);
|
||||||
|
|
||||||
|
%>
|
||||||
|
<%=jsonObject.toString() %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
|
||||||
|
public OptionVO getJobType() {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
LinkedList<String> xData = new LinkedList<>();
|
||||||
|
LinkedList<Integer> barSeriesData = new LinkedList<>();
|
||||||
|
String where = " and (h.belongto is null or h.belongto = -1 ) ";
|
||||||
|
|
||||||
|
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 "+where+" " +
|
||||||
|
" and g.id is not null group by g.id" +
|
||||||
|
" ) as a " +
|
||||||
|
" left join hrmjobgroups b on a.jobgroupid = b.id ");
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
String jobgroupname = Util.null2String(rs.getString("jobgroupname")) ;
|
||||||
|
int sum = Util.getIntValue(rs.getString("sum"));
|
||||||
|
if(StringUtils.isNotBlank(jobgroupname)){
|
||||||
|
xData.add(jobgroupname);
|
||||||
|
barSeriesData.add(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();
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
|||||||
|
<%@ 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue