%@ 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" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
String subcompanyid1 = "62";
JSONObject jsonObject = new JSONObject();
OptionVO optionVO = getPortalHomePlace(subcompanyid1);
jsonObject.put("data",optionVO);
%>
<%=jsonObject.toString() %>
<%!
public OptionVO getPortalHomePlace(String subcompanyid1) {
DecimalFormat df = new DecimalFormat("#.00");
RecordSet rs = new RecordSet();
LinkedList seriesData = new LinkedList<>();
LinkedList legendData = new LinkedList<>();
String where = " and (h.belongto is null or h.belongto = -1 ) and subcompanyid1 = "+subcompanyid1;
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" +
" where h.status < 4 and h.locationid is not null "+where+" " +
" group by h.locationid,l.locationname");
while (rs.next()) {
String locationname = Util.null2String(rs.getString("locationname"));
legendData.add(locationname);
seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("num"))).name(locationname).build());
}
// List values = seriesData.stream().map(SeriesParam :: getValue).collect(Collectors.toList());
// double percentage = values.stream().mapToDouble(Double::doubleValue).sum();
// seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage))));
return OptionVO.builder()
.titleText("归属地分析")
.legendDataFirst(legendData)
.seriesData(seriesData)
.build();
}
%>
<%!
/**
* 平分legendData
* @param nameSet
*/
private LinkedList treeSetSplitExample(LinkedList nameSet) {
int splitSize = nameSet.size() / 2;
LinkedList legendDataFirst = nameSet.stream()
.collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize,
Collectors.toCollection(LinkedList::new)))
.get(false);
nameSet.removeAll(legendDataFirst);
return legendDataFirst;
}
%>