1
0
Fork 0
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.

93 lines
3.2 KiB
Plaintext

<%@ 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;
}
%>