<%@ 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 language="java" contentType="text/html; charset=UTF-8" %> <% RecordSet rs = new RecordSet(); LinkedList xData = new LinkedList<>(); LinkedList yData = new LinkedList<>(); String where = " and (belongto is null or belongto = -1 ) "; List 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+"
"); 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+"
"); rs.executeQuery(sql); while (rs.next()){ String depid = Util.null2String(rs.getString("department_id")); deptids += StringUtils.isBlank(deptids) ? depid : ","+depid ; } out.println("deptids:"+deptids+"
"); List deptList = new ArrayList<>(); sql = " SELECT count(id) as num FROM hrmresource where status in (0,1) and departmentid in("+deptids+") "+where ; rs.executeQuery(sql); if (rs.next()) { int num = Util.getIntValue(rs.getString("num")); out.println("num:"+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); out.println(OptionVO.builder() .titleText("一级部门人数统计") .xData(xData) .yMin(0) .yMax(roundedMax) .yInterval(ceil) .yData(yData) .build()); %>