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.
52 lines
2.2 KiB
Plaintext
52 lines
2.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" %>
|
|
<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 = getHomePlace();
|
|
%>
|
|
<%=jsonObject.toString() %>
|
|
|
|
<%!
|
|
|
|
public OptionVO getHomePlace() {
|
|
RecordSet rs = new RecordSet();
|
|
List<String> colorList = Arrays.asList("#ao20f0","#8ac9e9","#697695","#83d8ae","#faf0e6","#7cfc00","#6e94f3","#9933fa","#c0ff3e","#00ced1","#ffe4c4","#cd6090");
|
|
LinkedList<SeriesParam> seriesData = new LinkedList<>();
|
|
LinkedList<String> legendData = new LinkedList<>();
|
|
|
|
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 group by h.locationid,l.locationname");
|
|
while (rs.next()) {
|
|
String locationname = Util.null2String(rs.getString("locationname"));
|
|
legendData.add(locationname);
|
|
Random random = new Random();
|
|
String color = colorList.get(random.nextInt(colorList.size()));
|
|
seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("num"))).name(locationname).color(color).build());
|
|
}
|
|
|
|
List<Double> 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();
|
|
}
|
|
%>
|
|
|
|
|
|
|
|
|