<%@ 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="java.text.DecimalFormat" %> <%@ page import="com.engine.matfron.entity.PortalTopVO" %> <%@ page import="com.engine.matfron.util.CommonUtils" %> <%@ page import="com.engine.matfron.util.CommonDateUtil" %> <%@ page import="java.time.YearMonth" %> <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% String subcompanyid1 = "62" ; JSONObject jsonObject = new JSONObject(); LinkedList list = getPortalTop(subcompanyid1); jsonObject.put("data",list); %> <%=jsonObject.toString() %> <%! public LinkedList getPortalTop(String subcompanyid1) { RecordSet rs = new RecordSet(); DecimalFormat df = new DecimalFormat("#.00"); BaseBean bb = new BaseBean(); LinkedList portalTopVOList = new LinkedList(); String where = " and (belongto is null or belongto = -1 ) "; rs.executeQuery("select count(1) as cou from hrmresource where status < 4 and subcompanyid1 ="+subcompanyid1 +where ); rs.next(); Integer count = Util.getIntValue(rs.getString("cou"), 0); portalTopVOList.add(PortalTopVO.builder().title("在职人数总数").count(count).build()); int sb_count = 0 ; String sql = " select count(1) as cou from hrsa_insurance_base_info where run_status in(2,3) and isnull(delete_type,0) !=1 " ; rs.executeQuery(sql); if(rs.next()){ sb_count = Util.getIntValue(rs.getString("cou"), 0); } portalTopVOList.add(PortalTopVO.builder().title("社保缴纳人数").count(sb_count).build()); List birthdayList = new ArrayList<>(); rs.executeQuery("select birthday from hrmresource where status < 4 and birthday is not null and subcompanyid1 ="+subcompanyid1+" and birthday <> '' "+where); while (rs.next()) { birthdayList.add(Util.null2String(rs.getString("birthday"))); } double averageAge = birthdayList.stream() .map(CommonUtils::parseLocalDate) .mapToInt(CommonUtils::calculateAge) .average() .orElse(0); String avgAge = df.format(averageAge); portalTopVOList.add(PortalTopVO.builder().title("平均年龄").count(avgAge).build()); int sum = 0; String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now())); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); sql = " select count(1) as sum from hrmresource where status < 4 and subcompanyid1 ="+subcompanyid1+" and companystartdate >= '"+startMonth+"' and companystartdate <= '"+endMonth+"'" + where ; bb.writeLog("sql:"+sql); rs.executeQuery(sql); if(rs.next()){ sum = Util.getIntValue(Util.null2String(rs.getString("sum")),0); } bb.writeLog("sum:"+sum); portalTopVOList.add(PortalTopVO.builder().title("本月新入职人员").count(sum).build()); return portalTopVOList; } %>