1
0
Fork 0

#matfron-2# 统计门户的元素优化

dev
shilei 1 year ago
parent 201b0d40e4
commit 21056c999d

@ -17,6 +17,25 @@
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd" ) ;
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ;
int days = 30 ;
String workflowid = "890";
String formtable = "" ;
String sql = "select abs(formid) as formid from workflow_base where id = "+workflowid ;
rs.executeQuery(sql);
if(rs.next()){
String formid = Util.null2String(rs.getString("formid"));
if(StringUtils.isNotBlank(formid)){
formtable = "formtable_main_"+formid ;
}
}
String where = "" ;
if(StringUtils.isNotBlank(formtable)){
where = " and h.id not in(select k.lzyg \n" +
" from workflow_requestbase p\n" +
" inner join "+formtable+" k on k.requestid = p.requestid\n" +
" where workflowid = "+workflowid+"\n" +
" and p.currentnodetype = 3 ) ";
}
for(int i=0;i<days;i++)
{
@ -27,7 +46,7 @@
String currentYear = sdf2.format(calendar.getTime()) ;
bb.writeLog("currentYear:"+currentYear);
String sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," +
sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," +
" h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," +
" (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as zn" +
" from hrmresource h\n" +
@ -37,7 +56,7 @@
" where right(h.companystartdate,5) = '"+currentDay+"'\n" +
" and h.status in(0,1,2,3)" +
" and (h.belongto is null or h.belongto = -1 ) " +
" and h.companystartdate is not null " +
" and h.companystartdate is not null " + where +
" ) k " ;
bb.writeLog("getCompanyAnniversary-sql:"+sql);
@ -92,7 +111,7 @@
String modeid = "" ;
String formid = "" ;
String uftable = "uf_rzznzfgly";
String sql =" select k.id,k.formid from modeinfo k \n" +
sql =" select k.id,k.formid from modeinfo k \n" +
" inner join workflow_bill l on formid = l.id\n" +
" where l.tablename = '"+uftable+"' " ;
rs.execute(sql);

@ -18,6 +18,28 @@
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ;
int days = 30 ;
String workflowid = "890";
out.println("workflowid:"+workflowid+"</br>");
String formtable = "" ;
String sql = "select abs(formid) as formid from workflow_base where id = "+workflowid ;
rs.executeQuery(sql);
if(rs.next()){
String formid = Util.null2String(rs.getString("formid"));
if(StringUtils.isNotBlank(formid)){
formtable = "formtable_main_"+formid ;
}
}
out.println("formtable:"+formtable+"</br>");
String where = "" ;
if(StringUtils.isNotBlank(formtable)){
where = " and h.id not in(select k.lzyg \n" +
" from workflow_requestbase p\n" +
" inner join "+formtable+" k on k.requestid = p.requestid\n" +
" where workflowid = "+workflowid+"\n" +
" and p.currentnodetype = 3 ) ";
}
out.println("where:"+where+"</br>");
for(int i=0;i<days;i++)
{
Calendar calendar = Calendar.getInstance();
@ -27,7 +49,7 @@
String currentYear = sdf2.format(calendar.getTime()) ;
out.println("currentYear:"+currentYear+"</br>");
String sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," +
sql = " select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," +
" h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," +
" (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as zn" +
" from hrmresource h\n" +
@ -36,7 +58,7 @@
" left join HrmJobTitles k on k.id = h.jobtitle\n" +
" where right(h.companystartdate,5) = '"+currentDay+"'\n" +
" and h.status in(0,1,2,3)" +
" and (h.belongto is null or h.belongto = -1 ) " +
" and (h.belongto is null or h.belongto = -1 ) " + where +
" and h.companystartdate is not null " +
" ) k " ;
@ -98,7 +120,7 @@
String currentYear = sdf2.format(calendar.getTime()) ;
out.println("currentYear:"+currentYear+"</br>");
String sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," +
sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," +
" h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," +
" (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as zn" +
" from hrmresource h\n" +
@ -107,7 +129,7 @@
" left join HrmJobTitles k on k.id = h.jobtitle\n" +
" where right(h.companystartdate,5) = '"+currentDay+"'\n" +
" and h.status in(0,1,2,3)" +
" and (h.belongto is null or h.belongto = -1 ) " +
" and (h.belongto is null or h.belongto = -1 ) " + where +
" and h.companystartdate is not null " +
" ) k " ;
@ -163,7 +185,7 @@
String modeid = "" ;
String formid = "" ;
String uftable = "uf_rzznzfgly";
String sql =" select k.id,k.formid from modeinfo k \n" +
sql =" select k.id,k.formid from modeinfo k \n" +
" inner join workflow_bill l on formid = l.id\n" +
" where l.tablename = '"+uftable+"' " ;
rs.execute(sql);

@ -0,0 +1,101 @@
<%@ 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 import="com.fasterxml.jackson.databind.ObjectMapper" %>
<%@ page import="com.fasterxml.jackson.core.JsonProcessingException" %>
<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 = getPortalDepartment();
jsonObject.put("data",optionVO);
%>
<%=jsonObject.toJSONString() %>
<%!
public OptionVO getPortalDepartment() {
RecordSet rs = new RecordSet();
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> yData = new LinkedList<>();
String where = " and (belongto is null or belongto = -1 ) ";
List<Integer> 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){
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 " ;
rs.executeQuery(sql);
while (rs.next()){
String depid = Util.null2String(rs.getString("department_id"));
deptids += StringUtils.isBlank(deptids) ? depid : ","+depid ;
}
List<DepartmentParam> deptList = new ArrayList<>();
sql = " SELECT count(id) as num FROM hrmresource where status < 4 and departmentid in("+deptids+") "+where ;
rs.executeQuery(sql);
if (rs.next()) {
int num = Util.getIntValue(rs.getString("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);
return OptionVO.builder()
.titleText("一级部门人数统计")
.xData(xData)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.yData(yData)
.build();
}
private static String getJsonString(Object apidatas) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(apidatas);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return "";
}
%>

@ -0,0 +1,83 @@
<%@ 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" %>
<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" %>
<%
RecordSet rs = new RecordSet();
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> yData = new LinkedList<>();
String where = " and (belongto is null or belongto = -1 ) ";
List<Integer> 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+"</br>");
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+"</br>");
rs.executeQuery(sql);
while (rs.next()){
String depid = Util.null2String(rs.getString("department_id"));
deptids += StringUtils.isBlank(deptids) ? depid : ","+depid ;
}
out.println("deptids:"+deptids+"</br>");
List<DepartmentParam> deptList = new ArrayList<>();
sql = " SELECT count(id) as num FROM hrmresource where status < 4 and departmentid in("+deptids+") "+where ;
rs.executeQuery(sql);
if (rs.next()) {
int num = Util.getIntValue(rs.getString("num"));
out.println("num:"+num+"</br>");
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());
%>

@ -0,0 +1,92 @@
<%@ 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;
}
%>

@ -36,7 +36,9 @@
" left join cus_selectitem k on k.selectvalue = t."+fieldname+"\n" +
" where k.fieldid="+fieldid+" \n" +
" and t."+fieldname+" is not null \n" +
" and scope = 'HrmCustomFieldByInfoType' and scopeid='3'\n" +
" and t.scope = 'HrmCustomFieldByInfoType' and t.scopeid='3' \n" +
" and h.status in(0,1,2,3)" +
" and (h.belongto is null or h.belongto = -1 ) " +
" group by t."+fieldname+",k.selectname \n" +
"");
while (rs.next()) {

@ -0,0 +1,70 @@
<%@ 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.OptionVO" %>
<%@ page import="java.time.YearMonth" %>
<%@ page import="com.engine.matfron.util.CommonDateUtil" %>
<%@ page import="java.time.LocalDate" %>
<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 = getPortalSubCompany();
jsonObject.put("data",optionVO);
jsonObject.put("status",true);
%>
<%=jsonObject.toJSONString() %>
<%!
public OptionVO getPortalSubCompany() {
RecordSet rs = new RecordSet();
LinkedList<Integer> yData = new LinkedList<>();
String where = " and (belongto is null or belongto = -1 ) ";
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
yearMonths.forEach(yearMonth -> {
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ?" + where ,endMonth);
if (rs.next()) {
Integer sum = Util.getIntValue(rs.getString("sum"),0);
yData.add(sum);
}
});
int max = Collections.max(yData);
int ceil =(int) Math.ceil((double) max / 5);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 5);
return OptionVO.builder()
.titleText("各月份分部总人数")
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.yData(yData)
.legendDataFirst(null)
.legendDataTwo(null)
.barSeriesData(null)
.barSeriesDataTwo(null)
.barSeriesDataThree(null)
.seriesData(null)
.build();
}
%>

@ -0,0 +1,92 @@
<%@ 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" %>
<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();
LinkedList<PortalTopVO> list = getPortalTop();
jsonObject.put("data",list);
%>
<%=jsonObject.toString() %>
<%!
public LinkedList<PortalTopVO> getPortalTop() {
RecordSet rs = new RecordSet();
DecimalFormat df = new DecimalFormat("#.00");
String subcompanyid1 = "62" ;
LinkedList<PortalTopVO> portalTopVOList = new LinkedList<PortalTopVO>();
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<String> 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());
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now()));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and subcompanyid1 ="+subcompanyid1+" and companystartdate >= ? and companystartdate <= " + where,startMonth,endMonth);
rs.next();
Integer sum = Util.getIntValue(rs.getString("sum"),0);
portalTopVOList.add(PortalTopVO.builder().title("本月新入职人员").count(sum).build());
return portalTopVOList;
}
%>
<%!
/**
* 平分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;
}
%>

@ -0,0 +1,93 @@
<%@ 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="com.engine.matfron.entity.OptionVO" %>
<%@ page import="java.time.LocalDate" %>
<%@ page import="java.time.Period" %>
<%@ page import="com.engine.matfron.util.CommonUtils" %>
<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 = getAgeAndSex();
jsonObject.put("data",OptionVO);
%>
<%=jsonObject.toString() %>
<%!
public OptionVO getAgeAndSex() {
RecordSet rs = new RecordSet();
LinkedList<Integer> barSeriesData = new LinkedList<>();
LinkedList<Integer> barSeriesDataTwo = new LinkedList<>();
List<String> ageArr = Arrays.asList("16~20","21~25","26~30","31~35","36~40","41~45","46~50","51~55","56~60","61~65","66~70");
String where = " and (belongto is null or belongto = -1 ) ";
List<String> birthdayListMen = new ArrayList<>();
rs.executeQuery("select birthday from hrmresource where status < 4 "+where+" and sex is not null and birthday is not null and birthday <> '' and sex = 0");
while (rs.next()) {
birthdayListMen.add(Util.null2String(rs.getString("birthday")));
}
List<Integer> menAge = birthdayListMen.stream()
.map(birthday -> {
LocalDate birthdate = LocalDate.parse(birthday);
LocalDate now = LocalDate.now();
return Period.between(birthdate, now).getYears();
})
.collect(Collectors.toList());
for (int i = 0; i < ageArr.size(); i++) {
String[] split = ageArr.get(i).split("~");
List<Integer> collect = menAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList());
barSeriesData.add(collect.size());
}
int yMax = barSeriesData.stream().max(Integer::compare).orElse(0);
List<String> birthdayListWomen = new ArrayList<>();
rs.executeQuery("select birthday from hrmresource where status < 4 "+where+" and sex is not null and birthday is not null and sex = 1");
while (rs.next()) {
birthdayListWomen.add(Util.null2String(rs.getString("birthday")));
}
List<Integer> womenAge = birthdayListWomen.stream()
.map(birthday -> {
LocalDate birthdate = LocalDate.parse(birthday);
LocalDate now = LocalDate.now();
return Period.between(birthdate, now).getYears();
})
.collect(Collectors.toList());
LinkedList<Integer> list = new LinkedList<>();
for (int i = 0; i < ageArr.size(); i++) {
String[] split = ageArr.get(i).split("~");
List<Integer> collect = womenAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList());
barSeriesDataTwo.add(-collect.size());
list.add(collect.size());
}
int yMin = -(list.stream().max(Integer::compare).orElse(0));
int sum = yMax > Math.abs(yMin) ? yMax : yMin ;
int divisor = sum % 6;
sum = sum + (6 - divisor) + 12;
int ceil =(int) Math.ceil((double) sum / 3);
int roundedMax = CommonUtils.roundedMax(ceil, 6);
return OptionVO.builder()
.titleText("年龄与性别分析")
.yMin(-roundedMax)
.yMax(roundedMax)
.yInterval(ceil)
.barSeriesData(barSeriesData)
.barSeriesDataTwo(barSeriesDataTwo)
.build();
}
%>

@ -0,0 +1,66 @@
<%@ 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.util.CommonUtils" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<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 = getJobType();
jsonObject.put("data",OptionVO);
%>
<%=jsonObject.toString() %>
<%!
public OptionVO getJobType() {
RecordSet rs = new RecordSet();
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> barSeriesData = new LinkedList<>();
String where = " and (h.belongto is null or h.belongto = -1 ) ";
rs.executeQuery(" select a.*,b.jobgroupname from ( " +
" select g.id as jobgroupid,count(1) as sum " +
" from hrmresource h \n" +
" left join hrmjobtitles j on h.jobtitle = j.id \n" +
" left join hrmjobactivities c on j.jobactivityid = c.id \n" +
" left join hrmjobgroups g on c.jobgroupid = g.id \n" +
" where h.status < 4 "+where+" " +
" and g.id is not null group by g.id" +
" ) as a " +
" left join hrmjobgroups b on a.jobgroupid = b.id ");
while (rs.next()) {
String jobgroupname = Util.null2String(rs.getString("jobgroupname")) ;
int sum = Util.getIntValue(rs.getString("sum"));
if(StringUtils.isNotBlank(jobgroupname)){
xData.add(jobgroupname);
barSeriesData.add(sum);
}
}
int max = Collections.max(barSeriesData);
int ceil =(int) Math.ceil((double) max / 4);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 4);
return OptionVO.builder()
.titleText("职务类别统计")
.xData(xData)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.barSeriesData(barSeriesData)
.build();
}
%>

@ -0,0 +1,72 @@
<%@ 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="com.engine.matfron.entity.OptionVO" %>
<%@ page import="com.engine.matfron.entity.SeriesParam" %>
<%@ page import="com.engine.matfron.entity.SurnameParam" %>
<%@ 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 = getSurname();
jsonObject.put("data",OptionVO);
%>
<%=jsonObject.toString() %>
<%!
public OptionVO getSurname() {
DecimalFormat df = new DecimalFormat("#.00");
RecordSet rs = new RecordSet();
LinkedList<SeriesParam> seriesData = new LinkedList<>();
String where = " and (belongto is null or belongto = -1 ) ";
List<SurnameParam> surnameList = new ArrayList<>();
rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " + where +
" and companyworkyear is not null group by companyworkyear ");
while (rs.next()) {
surnameList.add(SurnameParam.builder().companyworkyear(Util.getDoubleValue(rs.getString("companyworkyear"))).count(Util.getIntValue(rs.getString("sum"))).build());
}
List<Integer> statisticsArr = Arrays.asList(0,1,3,5,10,100);
List<Double> statisticsList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
double count = statisticsSurname(statisticsArr.get(i), statisticsArr.get(i+1), surnameList);
statisticsList.add(count);
}
double percentage = statisticsList.stream().mapToDouble(Double::doubleValue).sum();
List<Double> newList = statisticsList.stream()
.map(num -> Double.valueOf (df.format((num * 100 ) / percentage)))
.collect(Collectors.toList());
newList.forEach(count -> seriesData.add(SeriesParam.builder().value(count).build()));
return OptionVO.builder()
.titleText("司龄统计")
.seriesData(seriesData)
.build();
}
/**
* 根据范围统计司龄的个数
* @return
*/
private Double statisticsSurname(Integer min,Integer max,List<SurnameParam> surnameList) {
return surnameList.stream().filter(item -> item.getCompanyworkyear() > min && item.getCompanyworkyear() <= max)
.mapToDouble(SurnameParam::getCount).sum();
}
%>

@ -14,16 +14,37 @@
SimpleDateFormat sdf = new SimpleDateFormat("MM") ;
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ;
String workflowid = "890";
String formtable = "" ;
String sql = "select abs(formid) as formid from workflow_base where id = "+workflowid ;
rs.executeQuery(sql);
if(rs.next()){
String formid = Util.null2String(rs.getString("formid"));
if(StringUtils.isNotBlank(formid)){
formtable = "formtable_main_"+formid ;
}
}
String where = "" ;
if(StringUtils.isNotBlank(formtable)){
where = " and h.id not in(select k.lzyg \n" +
" from workflow_requestbase p\n" +
" inner join "+formtable+" k on k.requestid = p.requestid\n" +
" where workflowid = "+workflowid+"\n" +
" and p.currentnodetype = 3 ) ";
}
String currentMonth = sdf.format(new Date());
bb.writeLog("currentMonth:"+currentMonth);
String currentYear = sdf2.format(new Date());
bb.writeLog("currentYear:"+currentYear);
String sql =" select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname from hrmresource h\n" +
sql =" select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname from hrmresource h\n" +
" inner join HrmDepartment d on d.id = h.departmentid\n" +
" inner join HrmSubCompany s on s.id = h.subcompanyid1\n" +
" where right(left(h.birthday,7),2) ='"+currentMonth+"'\n" +
" and h.status in(0,1,2,3) and h.birthday is not null " +
" and h.status in(0,1,2,3) and h.birthday is not null " + where+
" and (h.belongto is null or h.belongto = -1 ) " ;
bb.writeLog("sql:"+sql);
rs.executeQuery(sql);

@ -13,6 +13,25 @@
BaseBean bb = new BaseBean();
SimpleDateFormat sdf = new SimpleDateFormat("MM") ;
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ;
String workflowid = "890";
String formtable = "" ;
String sql = "select abs(formid) as formid from workflow_base where id = "+workflowid ;
rs.executeQuery(sql);
if(rs.next()){
String formid = Util.null2String(rs.getString("formid"));
if(StringUtils.isNotBlank(formid)){
formtable = "formtable_main_"+formid ;
}
}
String where = "" ;
if(StringUtils.isNotBlank(formtable)){
where = " and h.id not in(select k.lzyg \n" +
" from workflow_requestbase p\n" +
" inner join "+formtable+" k on k.requestid = p.requestid\n" +
" where workflowid = "+workflowid+"\n" +
" and p.currentnodetype = 3 ) ";
}
String currentMonth = sdf.format(new Date()) ;
@ -20,12 +39,14 @@
String currentYear = sdf2.format(new Date()) ;
out.println("currentYear:"+currentYear+"</br>");
String sql =" select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname from hrmresource h\n" +
sql =" select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname from hrmresource h\n" +
" inner join HrmDepartment d on d.id = h.departmentid\n" +
" inner join HrmSubCompany s on s.id = h.subcompanyid1\n" +
" where right(left(h.birthday,7),2) ='"+currentMonth+"'\n" +
" and h.status in(0,1,2,3) and h.birthday is not null " +
" and h.status in(0,1,2,3) and h.birthday is not null " + where +
" and (h.belongto is null or h.belongto = -1 ) " ;
out.println("sql:"+sql+"</br>");
bb.writeLog("sql:"+sql);
rs.executeQuery(sql);
while (rs.next()){
@ -46,7 +67,7 @@
dataMap.put("nf",currentYear);
dataList.add(dataMap);
}
out.println("dataList:"+dataList.size()+"</br>");
String modeid = "" ;
String formid = "" ;

Loading…
Cancel
Save